public int Update(EmployeeApproval employeeApproval) { EmployeeApproval employeeApprovalToUpdate = context.EmployeeApprovals.SingleOrDefault(a => a.Id == employeeApproval.Id); employeeApprovalToUpdate.Status = employeeApproval.Status; return(context.SaveChanges()); }
public int Delete(int id) { EmployeeApproval employeeApprovalToDelete = context.EmployeeApprovals.SingleOrDefault(a => a.Id == id); context.EmployeeApprovals.Remove(employeeApprovalToDelete); return(context.SaveChanges()); }
private void HandleDelete(EmployeeApproval current, Action action) { EmployeeApprovalService.DeleteEmployeeApproval(current.EmployeeId, current.ApprovalId, (entity, response) => ThreadHelper.ExecuteOnUI(() => { if (CheckResponse(response)) { current.SetError(response.ApiErrorParamName, response.ErrorMessage); return; } action.Invoke(); })); }
private void HandleAddUpdate(EmployeeApproval current, Action action) { if (current.EmployeeApprovalId == 0) { current.EmployeeId = Employee.EmployeeId; EmployeeApprovalService.CreateEmployeeApproval(current, (entity, response) => HandleCommit(current, entity, response, action)); } else { EmployeeApprovalService.UpdateEmployeeApproval(current, (entity, response) => HandleCommit(current, entity, response, action)); } }
// GET: Mama public ActionResult Index(int id) { Mama mama = mamaRepo.GetByLogin(id); EmployeeApproval approval = approvalRepo.Get(mama.ApprovalId); if (approval.Status) { Session["MID"] = mama.Id; return(View(mama)); } else { return(View("Error")); } }
public ActionResult CreateMama(ViewMama vMama) { if (ModelState.IsValid) { EmployeeLogin login = new EmployeeLogin(); login.Username = vMama.Username; login.Password = vMama.Password; login.EmployeeType = "Mama"; WorkingArea area = new WorkingArea(); area.AreaId = vMama.WorkingArea; area.CityId = vMama.WorkingCity; Department dept = new Department(); dept.Id = vMama.DepartmentName; EmployeeApproval approval = new EmployeeApproval(); Mama mama = new Mama(); mama.FirstName = vMama.FirstName; mama.LastName = vMama.LastName; mama.Email = vMama.Email; mama.Phone = vMama.Phone; mama.JobType = vMama.JobType; mama.JoiningDate = vMama.JoiningDate.ToShortDateString(); mama.DateOfBirth = vMama.DateOfBirth.ToShortDateString(); mama.Department = dept; mama.Gender = vMama.Gender; mama.HouseNo = vMama.HouseNo; mama.RoadNo = vMama.RoadNo; mama.Salary = vMama.Salary; mama.LoginData = login; mama.DeliveryArea = area; mama.Approval = approval; mama.Area = areaRepo.Get(vMama.AreaName); mama.City = cityRepo.Get(vMama.CityName); mamaRepo.Insert(mama); return(RedirectToAction("LoadAdmin", "Employee", new { id = (int)Session["AID"] })); } else { return(View(vMama)); } }
public ActionResult LoadAdmin(int id) { Admin admin = adminRepo.GetByLogin(id); EmployeeApproval approval = approvalRepo.Get(admin.ApprovalId); if (approval.Status) { Session["AID"] = admin.Id; return(View(admin)); } else { return(View("Error")); } }
private void HandleCommit(EmployeeApproval current, EmployeeApproval result, IGSPServiceResponse response, Action action) { ThreadHelper.ExecuteOnUI(() => { if (CheckResponse(response)) { current.SetError(response.ApiErrorParamName, response.ErrorMessage); UpdateCommandsCanExecuteStatus(); return; } UpdateApprovals(); UpdateCurrentItem(result); action.Invoke(); UpdateCommandsCanExecuteStatus(); }); }
public int Insert(EmployeeApproval EmployeeApproval) { context.EmployeeApprovals.Add(EmployeeApproval); return(context.SaveChanges()); }
private void UpdateCurrentItem(EmployeeApproval result) { _approvals[_approvals.IndexOf((EmployeeApproval)PagedEmployeeApprovalViewCollection.CurrentItem)] = result; PagedEmployeeApprovalViewCollection.MoveCurrentTo(result); }