/// <summary> /// Returns true if the given leave allocation entity was successfully /// deleted from the database. The method returns false otherwise. /// </summary> public async Task <bool> Delete(LeaveAllocation entity) { _db.LeaveAllocations.Remove(entity); return(await Save()); }
public async Task <bool> Create(LeaveAllocation entity) { await _db.AddAsync(entity); return(await Save()); }
public bool Update(LeaveAllocation entity) { throw new NotImplementedException(); }
public bool Create(LeaveAllocation entity) { _dbContext.LeaveAllocation.Add(entity); return(Save()); }
public bool Update(LeaveAllocation entity) { _dbContext.LeaveAllocation.Update(entity); return(Save()); }
public bool Update(LeaveAllocation entity) { _db.LeaveAllocations.Update(entity); return(Save()); }
public bool Delete(LeaveAllocation item) { _db.LeaveAllocations.Remove(item); return(Save()); }
public async Task <bool> CreateAsync(LeaveAllocation entity) { await context.LeaveAllocations.AddAsync(entity).ConfigureAwait(false); return(await SaveAsync().ConfigureAwait(false) == 1); }
public bool Add(LeaveAllocation entity) { _context.LeaveAllocations.Add(entity); return(Save()); }
public LeaveAllocation GetById(int id) { LeaveAllocation leaveAllocation = DbContext.LeaveAllocations.Find(id); return(leaveAllocation); }
public ActionResult Create() { #region if (!_context.Roles.Any(x => x.Name == "Supervisor")) { _context.Roles.Add(new IdentityRole("Supervisor")); _context.SaveChanges(); } if (!_context.Roles.Any(x => x.Name == "Employee")) { _context.Roles.Add(new IdentityRole("Employee")); _context.SaveChanges(); } if (!_context.Roles.Any(x => x.Name == "Manager")) { _context.Roles.Add(new IdentityRole("Manager")); _context.SaveChanges(); } if (!_context.LeaveTypes.Any(x => x.LeaveTypeCode == "A0001")) { var annualLeaveType = new LeaveTypes { LeaveTypeCode = "A0001", LeaveTypeDescription = "Annual" }; _context.LeaveTypes.Add(annualLeaveType); _context.SaveChanges(); } if (!_context.LeaveTypes.Any(x => x.LeaveTypeCode == "C0001")) { var casualLeaveType = new LeaveTypes { LeaveTypeCode = "C0001", LeaveTypeDescription = "Casual" }; _context.LeaveTypes.Add(casualLeaveType); _context.SaveChanges(); } if (!_context.LeaveTypes.Any(x => x.LeaveTypeCode == "S0001")) { var sickLeaveType = new LeaveTypes { LeaveTypeCode = "S0001", LeaveTypeDescription = "Sick" }; _context.LeaveTypes.Add(sickLeaveType); _context.SaveChanges(); } if (!_context.EmployeeMaster.Any(x => x.EmployeeCode == "E0001")) { var employeeMaster = new EmployeeMaster { EmployeeCode = "E0001", EmployeeName = "Test Supervisor", EmployeeLeavePacakge = LeavePacakge.Wages, EmployeeType = EmployeeType.Supervisor, EmployeeSupervisorCode = "E0001" }; _context.EmployeeMaster.Add(employeeMaster); _context.SaveChanges(); var annualLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "A0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 10, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 10 }; _context.LeaveAllocation.Add(annualLeaveForOffice); _context.SaveChanges(); var casualLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "C0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 10, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 10 }; _context.LeaveAllocation.Add(casualLeaveForOffice); _context.SaveChanges(); var sickLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "S0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 10, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 10 }; _context.LeaveAllocation.Add(sickLeaveForOffice); _context.SaveChanges(); var newUser = new User { Username = employeeMaster.EmployeeCode, Password = employeeMaster.EmployeeCode }; _context.User.Add(newUser); _context.SaveChanges(); var userId = _context.User.ToList().Where(e => e.Username == employeeMaster.EmployeeCode).FirstOrDefault().UserId; var newUserRole = new UserRole { UserId = userId, Role = EmployeeType.Supervisor.ToString() }; _context.UserRole.Add(newUserRole); _context.SaveChanges(); } if (!_context.EmployeeMaster.Any(x => x.EmployeeCode == "E0002")) { var employeeMaster = new EmployeeMaster { EmployeeCode = "E0002", EmployeeName = "Test Employee", EmployeeLeavePacakge = LeavePacakge.Office, EmployeeType = EmployeeType.Employee, EmployeeSupervisorCode = "E0001" }; _context.EmployeeMaster.Add(employeeMaster); _context.SaveChanges(); var annualLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "A0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 14, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 14 }; _context.LeaveAllocation.Add(annualLeaveForOffice); _context.SaveChanges(); var casualLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "C0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 7, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 7 }; _context.LeaveAllocation.Add(casualLeaveForOffice); _context.SaveChanges(); var sickLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "S0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 21, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 21 }; _context.LeaveAllocation.Add(sickLeaveForOffice); _context.SaveChanges(); var newUser = new User { Username = employeeMaster.EmployeeCode, Password = employeeMaster.EmployeeCode }; _context.User.Add(newUser); _context.SaveChanges(); var userId = _context.User.ToList().Where(e => e.Username == employeeMaster.EmployeeCode).FirstOrDefault().UserId; var newUserRole = new UserRole { UserId = userId, Role = EmployeeType.Employee.ToString() }; _context.UserRole.Add(newUserRole); _context.SaveChanges(); } #endregion return(View()); }
public void Delete(LeaveAllocation entity) { DbContext.LeaveAllocations.Remove(entity); DbContext.SaveChanges(); }
public ActionResult Create([Bind(Include = "EmployeeId,EmployeeCode,EmployeeName,EmployeeSupervisorCode,EmployeeLeavePacakge")] EmployeeMaster employeeMaster, string employeeType, string supervisorCode) { var supervisor_Code = supervisorCode; if (supervisor_Code == null || supervisor_Code == "") { supervisor_Code = employeeMaster.EmployeeCode; } if (employeeMaster.EmployeeCode != null && employeeMaster.EmployeeName != null && supervisor_Code != null && employeeMaster.EmployeeCode != "" && employeeMaster.EmployeeLeavePacakge.ToString() != "" && employeeMaster.EmployeeName != "" && supervisor_Code != "") { var existingEmployee = db.EmployeeMaster.ToList().Where(e => e.EmployeeCode == employeeMaster.EmployeeCode || e.EmployeeName == employeeMaster.EmployeeName).ToList(); if (existingEmployee.Count == 0) { if (ModelState.IsValid) { EmployeeType empType = (EmployeeType)Enum.Parse(typeof(EmployeeType), employeeType); var empMaster = new EmployeeMaster { EmployeeCode = employeeMaster.EmployeeCode, EmployeeName = employeeMaster.EmployeeName, EmployeeLeavePacakge = employeeMaster.EmployeeLeavePacakge, EmployeeType = empType, EmployeeSupervisorCode = supervisor_Code }; db.EmployeeMaster.Add(empMaster); db.SaveChanges(); if (employeeMaster.EmployeeLeavePacakge.ToString() == "Office") { var annualLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "A0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 14, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 14 }; db.LeaveAllocation.Add(annualLeaveForOffice); db.SaveChanges(); var casualLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "C0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 7, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 7 }; db.LeaveAllocation.Add(casualLeaveForOffice); db.SaveChanges(); var sickLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "S0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 21, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 21 }; db.LeaveAllocation.Add(sickLeaveForOffice); db.SaveChanges(); } else if (employeeMaster.EmployeeLeavePacakge.ToString() == "Wages") { var annualLeaveForWages = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "A0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 10, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 10 }; db.LeaveAllocation.Add(annualLeaveForWages); db.SaveChanges(); var casualLeaveForWages = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "C0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 10, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 10 }; db.LeaveAllocation.Add(casualLeaveForWages); db.SaveChanges(); var sickLeaveForWages = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "S0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 10, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 10 }; db.LeaveAllocation.Add(sickLeaveForWages); db.SaveChanges(); } var newUser = new User { Username = employeeMaster.EmployeeCode, Password = employeeMaster.EmployeeCode }; db.User.Add(newUser); db.SaveChanges(); var userId = db.User.ToList().Where(e => e.Username == employeeMaster.EmployeeCode).FirstOrDefault().UserId; if (employeeType == "Normal") { var newUserRole = new UserRole { UserId = userId, Role = employeeType }; db.UserRole.Add(newUserRole); db.SaveChanges(); } else { var newUserRole = new UserRole { UserId = userId, Role = employeeType }; db.UserRole.Add(newUserRole); db.SaveChanges(); } return(RedirectToAction("Index")); } ViewData["EmployeeType"] = Enum.GetValues(typeof(EmployeeType)); ViewData["Supervisor"] = db.EmployeeMaster.ToList(); return(View(employeeMaster)); } else { TempData["ErrorMessage"] = "Employee Exist !!! "; } } else { TempData["ErrorMessage"] = "Please fill all the fields !"; } ViewData["EmployeeType"] = Enum.GetValues(typeof(EmployeeType)); ViewData["Supervisor"] = db.EmployeeMaster.ToList(); return(View()); }
public bool Update(LeaveAllocation item) { _db.Add(item); return(Save()); }
public bool Create(LeaveAllocation entity) { _db.LeaveAllocations.Add(entity); return(Save()); }
public bool Remove(LeaveAllocation entity) { _context.LeaveAllocations.Remove(entity); return(Save()); }
public bool Delete(LeaveAllocation entity) { _db.LeaveAllocations.Remove(entity); return(Save()); }
public bool Update(int id, LeaveAllocation entity) { _context.LeaveAllocations.Update(entity); return(Save()); }
public async Task <bool> Create(LeaveAllocation entity) { _db.LeaveAllocations.Add(entity); return(await Save()); }
public async Task <bool> Update(LeaveAllocation entity) { db.LeaveAllocations.Update(entity); return(await Save()); }