Ejemplo n.º 1
0
        public ActionResult Add(EmployeeLeave employeeLeave, string Command)
        {
            Employee emp = (Employee)Session["Employee"];

            employeeLeave.EmpID = emp.ID;
            if (ModelState.IsValid)
            {
                if (Command == "Save as Draft")
                {
                    employeeLeave.Status = LeaveStatus.Draft;
                    leaveRepository.AddEmployeeLeave(employeeLeave);

                    return(View("DraftMessage", employeeLeave));
                }
                else
                {
                    employeeLeave.Status = LeaveStatus.Pending;
                    leaveRepository.AddEmployeeLeave(employeeLeave);
                    return(View("ConfirmLeave", employeeLeave));
                }
            }
            else
            {
                var selectLeaveTypes        = new List <SelectListItem>();
                List <LeaveType> leaveTypes = leaveRepository.GetAllLeaves();
                foreach (var leave in leaveTypes)
                {
                    selectLeaveTypes.Add(new SelectListItem {
                        Text = (leave.Description + "(" + leave.Code + ")"), Value = leave.ID.ToString()
                    });
                }
                ViewBag.LeaveTypeID = selectLeaveTypes;
                return(View(employeeLeave));
            }
        }