public int AddLeavePlan(LeavePlanDTO objLeavePlan) { try { // insert plan if (objLeavePlan.ID == 0) { decimal maxId = context.LeavePlans.Select(mm => mm.ID).DefaultIfEmpty(0).Max(); objLeavePlan.ID = ++maxId; LeavePlan target = new LeavePlan(); objLeavePlan.Mapper(target); context.LeavePlans.Add(target); } else { // update plan LeavePlan exPlan = context.LeavePlans.Where(ll => ll.ID == objLeavePlan.ID).FirstOrDefault(); exPlan.EmpId = objLeavePlan.EmpId; exPlan.LTypeId = objLeavePlan.LTypeId; exPlan.StartDate = objLeavePlan.StartDate; exPlan.EndDate = objLeavePlan.EndDate; exPlan.Remarks = objLeavePlan.Remarks; exPlan.IsActive = objLeavePlan.IsActive; } int cnt = context.SaveChanges(); return(cnt); } catch (Exception exc) { return(0); } }
// // GET: /LeavePlan/Details/5 public ActionResult Details(int id = 0) { LeavePlan leaveplan = TimesheetRepository.GetLeavePlanById(id); if (leaveplan == null) { return(HttpNotFound()); } return(View(leaveplan)); }
public ActionResult Edit(LeavePlan leaveplan) { if (ModelState.IsValid) { TimesheetRepository.AddUpdateLeavePlan(leaveplan); return(RedirectToAction("Index")); } ViewBag.LeaveCategoryId = new SelectList(TimesheetRepository.GetLeaveCategories(), "LeaveCategoryId", "LeaveCategoryDesc", leaveplan.LeaveCategoryId); ViewBag.PersonId = new SelectList(TimesheetRepository.GetAllPersons(), "PersonId", "PersonName", leaveplan.PersonId); return(View(leaveplan)); }
// // GET: /LeavePlan/Edit/5 public ActionResult Edit(int id = 0) { LeavePlan leaveplan = TimesheetRepository.GetLeavePlanById(id); if (leaveplan == null) { return(HttpNotFound()); } ViewBag.LeaveCategoryId = new SelectList(TimesheetRepository.GetLeaveCategories(), "LeaveCategoryId", "LeaveCategoryDesc", leaveplan.LeaveCategoryId); ViewBag.PersonId = new SelectList(TimesheetRepository.GetAllPersons(), "PersonId", "PersonName", leaveplan.PersonId); return(View(leaveplan)); }
public async Task <CreatedDto> Handle(CreateLeavePlanCommand request, CancellationToken cancellationToken) { var entity = new LeavePlan() { Name = request.Name }; var leaveTypeEntityList = await context //.AsNoTracking() .LeaveTypes .ToListAsync(); var leavePlanAssignmentList = request.Leaves.Select(l => { var leaveType = leaveTypeEntityList.SingleOrDefault(lt => lt.Id.Equals(l.Key)); if (leaveType == null) { throw new EntityNotFoundException(nameof(LeaveType), l.Key); } return(new LeavePlanAssignment { LeaveType = leaveType, Amount = l.Value, LeavePlan = entity, }); }); context.LeavePlanAssignments.AddRange(leavePlanAssignmentList); await context.SaveChangesAsync(cancellationToken); return(new CreatedDto { Id = entity.Id }); }
public static IEnumerable <LeavePlan> GetAllPersonsBySupervisorId(int SupervisorId) { return(LeavePlan.GetAllLeavePlansBySupervisorId(SupervisorId)); }
public static IEnumerable <LeavePlan> AdmitReject(int LeavePlanId, bool AdmitReject) { return(LeavePlan.AdmitOrRejectLeaves(LeavePlanId, AdmitReject)); }
public static bool RemoveLeavePlan(int leavePlanId) { return(LeavePlan.Delete(leavePlanId)); }
public static LeavePlan AddUpdateLeavePlan(LeavePlan leavePlan) { return(LeavePlan.Save(leavePlan)); }
public static IEnumerable <LeavePlan> GetLeavePlansForTeam(int userId) { return(LeavePlan.GetAllLeavePlansForTeam(userId)); }
public static IEnumerable <LeavePlan> GetLeavePlans() { return(LeavePlan.GetAll()); }
//-------------------------------------------------------------------------------- public static LeavePlan GetLeavePlanById(int leavePlanId) { return(LeavePlan.GetById(leavePlanId)); }