예제 #1
0
        public ActionResult Create(LeaveCreationViewModel model)
        {
            try
            {
                var employeeId         = CurrentLoggedInUser.EmployeeId;
                var leaveOrchestration = Factory.CreateInstance <ILeaveOrchestration>();
                var outcome            = leaveOrchestration.RequestLeave(employeeId, model.FromDate, model.ToDate, model.LeaveBalanceInDays, model.LeaveTypeId, model.Comments);

                if (!outcome.IsSuccessful)
                {
                    var masterDataOrchestration = Factory.CreateInstance <IMasterDataOrchestration>();
                    var leaveTypes = masterDataOrchestration.GetLeaveTypes();
                    model.LeaveTypes = leaveTypes.Data.Map();

                    ModelState.AddModelError(string.Empty, outcome.ErrorMessage);

                    return(View(model));
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
예제 #2
0
        public static LeaveCreationViewModel MapEdit(this LeaveRequestModel original)
        {
            var mappedOutcome = new LeaveCreationViewModel
            {
                LeaveBalanceInDays   = original.Balance,
                Comments             = original.Comments,
                FromDate             = original.StartDate,
                ToDate               = original.EndDate,
                Balance              = original.Balance,
                LeaveRequestedInDays = original.RequestedDays,
                LeaveTypeId          = original.LeaveRequestId
            };

            return(mappedOutcome);
        }