

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;
using Telerik.OpenAccess;

#pragma warning disable 1591

namespace ComboBoxDemo.Web	
{    
    [EnableClientAccess()]
    public partial class AdresarDomainService : OpenAccessDomainService< AdresarEntityDiagrams >
    {
        public AdresarDomainService() : base()
        {
        }
        
        public IQueryable<Osoba> GetOsobas()
        { 
            return this.DataContext.Osobas;
        }

        [RequiresAuthentication()]
        public Osoba GetOsobaById()
        {
            //var osoba = this.DataContext.Osobas.FirstOrDefault();
            return this.DataContext.Osobas.FirstOrDefault(x => x.ID == 2);
        }

        public MyUser GetUserName()
        {
            return new MyUser(((System.Web.HttpContext.Current.User).Identity).Name);
        }

        //public string[] GetUserName()
        //{
        //    return new string[] { ((System.Web.HttpContext.Current.User).Identity).Name };
        //}

        public void DeleteOsobas(Osoba osoba)
        {
            // This is a callback method. The actual Delete is performed internally.
        }

        public void UpdateOsobas(Osoba osoba)
        {
            // This is a callback method. The actual Update is performed internally.
        }

        public void InsertOsobas(Osoba osoba)
        {
            // This is a callback method. The actual Insert is performed internally.
        } 
        public IQueryable<Pohlavi> GetPohlavis()
        { 
            return this.DataContext.Pohlavis;
        }       
        public void DeletePohlavis(Pohlavi pohlavi)
        {
            // This is a callback method. The actual Delete is performed internally.
        }

        public void UpdatePohlavis(Pohlavi pohlavi)
        {
            // This is a callback method. The actual Update is performed internally.
        }

        public void InsertPohlavis(Pohlavi pohlavi)
        {
            // This is a callback method. The actual Insert is performed internally.
        } 
    }

    public class MyUser
    {
        public MyUser()
        {
            this.UserName = string.Empty;
        }

        public MyUser(string userName)
        {
            this.UserName = userName;        
        }

        [Key]
        public string UserName { get; set; }
    }
}

#pragma warning restore 1591
