예제 #1
0
        public EmpModels GetEmployess(int id)
        {
            using (var context = new DXCEntities())
            {
                var result = context.Db_approach
                             .Where(x => x.Id == id)
                             .Select(x => new EmpModels()

                {
                    Id        = x.Id,
                    Addressid = x.Addressid,
                    Code      = x.Code,
                    Email     = x.Email,
                    FirstName = x.FirstName,
                    LastName  = x.LastName,
                    Address   = new AddressModels()
                    {
                        Id      = x.Db_address.Id,
                        Details = x.Db_address.Details,
                        Country = x.Db_address.Country,
                        State   = x.Db_address.State
                    }
                }).FirstOrDefault();

                return(result);
            }
        }
예제 #2
0
        public List <EmpModels> GetAllEmployess()
        {
            using (var context = new DXCEntities())
            {
                var result = context.Db_approach.Select(x => new EmpModels()

                {
                    Id        = x.Id,
                    Addressid = x.Addressid,
                    Code      = x.Code,
                    Email     = x.Email,
                    FirstName = x.FirstName,
                    LastName  = x.LastName,
                    Address   = new AddressModels()
                    {
                        Id      = x.Db_address.Id,
                        Details = x.Db_address.Details,
                        Country = x.Db_address.Country,
                        State   = x.Db_address.State
                    }
                }).ToList();

                return(result);
            }
        }
예제 #3
0
 public bool DeleteEmploy(int id)
 {
     using (var context = new DXCEntities())
     {
         var empl = context.Db_approach.FirstOrDefault(x => x.Id == id);
         if (empl != null)
         {
             context.Db_approach.Remove(empl);
             context.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
예제 #4
0
 public bool UpdateEmploye(int id, EmpModels model)
 {
     using (var context = new DXCEntities())
     {
         var empl = context.Db_approach.FirstOrDefault(x => x.Id == id);
         if (empl != null)
         {
             empl.FirstName = model.FirstName;
             empl.LastName  = model.LastName;
             empl.Email     = model.Email;
             empl.Code      = model.Code;
         }
         context.SaveChanges();
         return(true);
     }
 }
예제 #5
0
        public int AddEmploye(EmpModels model)
        {
            using (var context = new DXCEntities())
            {
                Db_approach ee = new Db_approach()
                {
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    Email     = model.Email,
                    Code      = model.Code
                };
                context.Db_approach.Add(ee);

                context.SaveChanges();

                return(ee.Id);
            }
        }