public void AddProduct(DATA.Domains.Product product) { using (UbDbcontext context = new UbDbcontext()) { context.Product.Add(product); context.SaveChanges(); } }
public void AddEmployee(DATA.Domains.Employee employee) { using (UbDbcontext context = new UbDbcontext()) { context.Employee.Add(employee); context.SaveChanges(); } }
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(); } }
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(); } }
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; } } }