Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        //
        // GET: /LeavePlan/Details/5

        public ActionResult Details(int id = 0)
        {
            LeavePlan leaveplan = TimesheetRepository.GetLeavePlanById(id);

            if (leaveplan == null)
            {
                return(HttpNotFound());
            }
            return(View(leaveplan));
        }
Ejemplo n.º 3
0
 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));
 }
Ejemplo n.º 4
0
        //
        // 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
                });
            }
Ejemplo n.º 6
0
 public static IEnumerable <LeavePlan> GetAllPersonsBySupervisorId(int SupervisorId)
 {
     return(LeavePlan.GetAllLeavePlansBySupervisorId(SupervisorId));
 }
Ejemplo n.º 7
0
 public static IEnumerable <LeavePlan> AdmitReject(int LeavePlanId, bool AdmitReject)
 {
     return(LeavePlan.AdmitOrRejectLeaves(LeavePlanId, AdmitReject));
 }
Ejemplo n.º 8
0
 public static bool RemoveLeavePlan(int leavePlanId)
 {
     return(LeavePlan.Delete(leavePlanId));
 }
Ejemplo n.º 9
0
 public static LeavePlan AddUpdateLeavePlan(LeavePlan leavePlan)
 {
     return(LeavePlan.Save(leavePlan));
 }
Ejemplo n.º 10
0
 public static IEnumerable <LeavePlan> GetLeavePlansForTeam(int userId)
 {
     return(LeavePlan.GetAllLeavePlansForTeam(userId));
 }
Ejemplo n.º 11
0
 public static IEnumerable <LeavePlan> GetLeavePlans()
 {
     return(LeavePlan.GetAll());
 }
Ejemplo n.º 12
0
 //--------------------------------------------------------------------------------
 public static LeavePlan GetLeavePlanById(int leavePlanId)
 {
     return(LeavePlan.GetById(leavePlanId));
 }