Example #1
0
        public ActionResult Create(LeaveApplicationDTOs Record, int levid)
        {
            string recommendType = "General";
            int    empcode       = Convert.ToInt32(Session["EmpCode"]);

            Record.ApproverList    = _DynamicSelectList.GetLeaveApproverSelectList(empcode, recommendType).ToList();
            Record.RecommenderList = _DynamicSelectList.GetLeaveRecommenderSelectList(empcode, recommendType).ToList();
            try
            {
                Record.LeaveStartDate = Convert.ToDateTime(NepEngDate.NepToEng(Record.LeaveStartDateNP));
                Record.LeaveEndDate   = Convert.ToDateTime(NepEngDate.NepToEng(Record.LeaveEndDateNP));

                if (Record.IsHalfDay)
                {
                    Record.LeaveEndDate = Record.LeaveStartDate;
                }

                if (ModelState.IsValid)
                {
                    Record = _ValidateLeave.ValidateLeave(Record);

                    if (Record.ErrorList != null && Record.ErrorList.Count > 0)
                    {
                        return(View(Record));
                    }
                    else
                    {
                        _LeaveAddAdmin.LeaveApplicationCreate(Record);
                        Session["success"] = "Leave Created Sucessfully ";
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    Record.ApproverList = _LeaveAddAdmin.CreateLeaveApplicationInformation(empcode, Record.LeaveTypeId, recommendType).ApproverList;

                    return(View(Record));
                }
            }
            catch (Exception Ex)
            {
                Session["error"]    = Ex.Message;
                Record.ApproverList = _LeaveAddAdmin.CreateLeaveApplicationInformation(empcode, Record.LeaveTypeId, recommendType).ApproverList;

                return(View(Record));
            }
        }
        public ActionResult Create(LeaveApplicationDTOs Record, int EmpCode, int levid)
        {
            string recommendType = "General";

            Record.LeaveStartDate = !string.IsNullOrEmpty(Record.LeaveStartDateNP) ? Convert.ToDateTime(NepEngDate.NepToEng(Record.LeaveStartDateNP)) : Record.LeaveStartDate;
            Record.LeaveEndDate   = !string.IsNullOrEmpty(Record.LeaveEndDateNP) ? Convert.ToDateTime(NepEngDate.NepToEng(Record.LeaveEndDateNP)) : Record.LeaveEndDate;

            try
            {
                if (Record.IsHalfDay == true)
                {
                    Record.LeaveEndDate = Record.LeaveStartDate;
                }


                if (ModelState.IsValid)
                {
                    LeaveApplicationDTOs data = _ValidateLeave.ValidateLeave(Record);

                    if (data.ErrorList != null && data.ErrorList.Count > 0)
                    {
                        data.RecommenderList = _DynamicSelectList.GetLeaveRecommenderSelectList(EmpCode, recommendType).ToList();
                        data.ApproverList    = _LeaveAddAdmin.CreateLeaveApplicationInformation(EmpCode, levid, recommendType).ApproverList;
                        return(View(data));
                    }
                    else
                    {
                        _LeaveAddAdmin.LeaveApplicationCreate(Record);
                        Session["success"] = "Leave Created Sucessfully ";
                        return(RedirectToAction("LeaveApplistList", new { EmpCode = EmpCode }));
                    }
                }
                else
                {
                    Record.RecommenderList = _DynamicSelectList.GetLeaveRecommenderSelectList(EmpCode, recommendType).ToList();
                    Record.ApproverList    = _LeaveAddAdmin.CreateLeaveApplicationInformation(EmpCode, levid, recommendType).ApproverList;
                    return(View(Record));
                }
            }
            catch (Exception Ex)
            {
                Session["error"]       = Ex.Message;
                Record.RecommenderList = _DynamicSelectList.GetLeaveRecommenderSelectList(EmpCode, recommendType).ToList();
                Record.ApproverList    = _LeaveAddAdmin.CreateLeaveApplicationInformation(EmpCode, levid, recommendType).ApproverList;
                return(View(Record));
            }
        }