示例#1
0
 public void AddProduct(DATA.Domains.Product product)
 {
     using (UbDbcontext context = new UbDbcontext())
     {
         context.Product.Add(product);
         context.SaveChanges();
     }
 }
示例#2
0
 public void AddEmployee(DATA.Domains.Employee employee)
 {
     using (UbDbcontext context = new UbDbcontext())
     {
         context.Employee.Add(employee);
         context.SaveChanges();
     }
 }
示例#3
0
        public void DeleteEmployee(int id)
        {
            using (UbDbcontext context = new UbDbcontext())
            {
                var employeeToDelete = context.Employee.Where(x => x.Id == id).FirstOrDefault();
                employeeToDelete.IsDeleted = true;
                employeeToDelete.IsActive  = false;

                context.SaveChanges();
            }
        }
示例#4
0
        public void UpdateEmployee(DATA.Domains.Employee employee)
        {
            using (UbDbcontext context = new UbDbcontext())
            {
                var employeeToUpdate = context.Employee.Where(x => x.Id == employee.Id).FirstOrDefault();

                employeeToUpdate.FirstName    = employee.FirstName;
                employeeToUpdate.LastName     = employee.LastName;
                employeeToUpdate.CNIC         = employee.CNIC;
                employeeToUpdate.CellNo       = employee.CellNo;
                employeeToUpdate.DepartmentId = employee.DepartmentId;

                context.SaveChanges();
            }
        }
示例#5
0
        public void AddAttendace(DATA.Domains.Attendance attendance)
        {
            using (UbDbcontext context = new UbDbcontext())
            {
                try
                {
                    var already = context.Attendance.Where(x => x.EmployeeName == attendance.EmployeeName && x.Date == attendance.Date).ToList();


                    if (!already.Any())
                    {
                        context.Attendance.Add(attendance);

                        context.SaveChanges();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }