예제 #1
0
 public ActionResult Approve(int id)
 {
     try
     {
         ChangeStatusOfLOA(id, "Approved");
         LOAService loaService = new LOAService();
         var        loa        = loaService.GetJustLOA(id);
         if (loa == null)
         {
             TempData["error"] = "LOA does not exist or you dont have permissions";
             return(RedirectToAction("EmployeeRepomanLOAList"));
         }
         var         userId      = User.Identity.GetUserId();
         UserService userService = new UserService();
         var         user        = userService.GetUserWithId(userId);
         loa.ApprovedBy     = user.Firstname + " " + user.LastName + " (" + user.EmployeeCode + ")";
         loa.ModifiedDate   = DateTime.Now;
         loa.ModifiedUserId = User.Identity.GetUserId();
         loaService.UpdateLOA(loa);
         TempData["status"] = "LOA " + loa.LoaCode + " has been approved";
         return(RedirectToAction("EmployeeRepomanLOAList"));
     }
     catch (Exception ex)
     {
         TempData["error"] = "Something went wrong while Approving";
         return(RedirectToAction("EmployeeRepoManLOAList"));
     }
 }
예제 #2
0
        public ActionResult EmployeeAdminLOADelete(int id)
        {
            try
            {
                LOAService loaService = new LOAService();

                var loa = loaService.GetJustLOA(id);
                if (loa == null)
                {
                    TempData["error"] = "LOA does not exist";
                    return(RedirectToAction("EmployeeAdminLOAList"));
                }
                loa.IsDeleted      = true;
                loa.IsActive       = false;
                loa.ModifiedUserId = User.Identity.GetUserId();
                loa.ModifiedDate   = DateTime.Now;

                loaService.UpdateLOA(loa);

                TempData["status"] = "LOA " + loa.LoaCode + " successfully deleted";
                return(RedirectToAction("EmployeeAdminLOAList"));
            }
            catch
            {
                TempData["error"] = "Something went wrong while deleting LOA";
                return(RedirectToAction("EmployeeAdminLOAList"));
            }
        }
예제 #3
0
        public async Task <ActionResult> Reject(LoaViewModel lvm)
        {
            try
            {
                //if(string.IsNullOrEmpty(tsvm.TempComments))
                //{
                //    return Json(new { HasErrors= true, Errors = "Comments are Mandatory"});
                //}

                LOAService loaService = new LOAService();

                var loa = loaService.GetJustLOA(lvm.LoaId);
                if (loa == null)
                {
                    TempData["error"] = "LOA does not exist or you dont have permissions";
                    return(RedirectToAction("EmployeeRepomanLOAList"));
                }
                loa.LookupLoaStatus = loaService.GetLookupIdForCodeName("Rejected", "LoaStatus").LookupCodeId;
                loa.Comments       += " " + lvm.TempComments + " (" + DateTime.Now.ToString() + "), <br> ";
                loa.ModifiedDate    = DateTime.Now;
                loa.ModifiedUserId  = User.Identity.GetUserId();
                loaService.UpdateLOA(loa);
                await SendEmailLOARejected(lvm.LoaId);

                TempData["status"] = "LOA " + loa.LoaCode + " has been rejected and mail has been sent to employee";
                return(null);
            }
            catch (Exception ex)
            {
                TempData["error"] = "Something went wrong while Rejecting";
                return(RedirectToAction("EmployeeRepoManLOAList"));
            }
        }
예제 #4
0
        private void ChangeStatusOfLOA(int id, string status)
        {
            LOAService loaService = new LOAService();
            var        loa        = loaService.GetJustLOA(id);

            loa.LookupLoaStatus = loaService.GetLookupIdForCodeName(status, "LoaStatus").LookupCodeId;
            loa.ModifiedDate    = DateTime.Now;
            loa.ModifiedUserId  = User.Identity.GetUserId();
            loaService.UpdateLOA(loa);
        }
예제 #5
0
        public ActionResult EmployeeManagerLOADownload(int id)
        {
            try
            {
                LoaViewModel lvm        = new LoaViewModel();
                LOAService   loaService = new LOAService();

                var loa = new LOA();


                loa = loaService.GetLOA(id);


                if (loa == null)
                {
                    TempData["error"] = "Either this file does not exist or you dont have permissions";
                    return(RedirectToAction("EmployeeManagerLOAList"));
                }

                lvm = Mapper.Map <LOA, LoaViewModel>(loa);

                lvm.TimeOfDayList          = GetDropDownList("LoaTimeOfDay", null);
                lvm.TypeOfLeaveList        = GetDropDownList("LoaTypeOfLeave", null);
                lvm.LookupOtherTimeOfDay   = loaService.GetLookupIdForCodeName("Other", "LoaTimeOfDay").LookupCodeId;
                lvm.LookupOtherTypeOfLeave = loaService.GetLookupIdForCodeName("Other", "LoaTypeOfLeave").LookupCodeId;

                //var typeOfleaveDDL = new SelectList(lvm.TypeOfLeaveList, "Id", "Name");
                if (lvm.LookupTypeOfLeave != lvm.LookupOtherTypeOfLeave)
                {
                    var leaveType = lvm.TypeOfLeaveList.Where(x => x.Id == lvm.LookupTypeOfLeave).First().Name;
                    lvm.OtherTypeOfLeave = leaveType;
                }
                if (lvm.LookupTimeOfDay != lvm.LookupOtherTimeOfDay)
                {
                    var timeOfDay = lvm.TimeOfDayList.Where(x => x.Id == lvm.LookupTimeOfDay).First().Name;
                    lvm.OtherTimeOfDay = timeOfDay;
                }

                if (lvm.AspNetUser.AspNetUser1 != null)
                {
                    lvm.ReportingManager = lvm.AspNetUser.AspNetUser1.Firstname + " " + lvm.AspNetUser.AspNetUser1.LastName;
                }
                else
                {
                    lvm.ReportingManager = "None";
                }

                return(PartialView("_DownloadLOAView", lvm));
            }
            catch (Exception ex)
            {
                TempData["error"] = "Something went wrong while downloading";
                return(RedirectToAction("EmployeeManagerLOAList"));
            }
        }
예제 #6
0
        public ActionResult GetEmployeeAdminPendingLOAList()
        {
            LOAService loaService = new LOAService();

            List <LOA> loas = new List <LOA> ();

            loas = loaService.GetEmployeePendingLOAs();

            var loaList = Mapper.Map <List <LOA>, List <LoaListViewModel> >(loas);

            ViewBag.TSRole = "TimeSheetAdmin";

            return(PartialView("_EmployeePendingLOAList", loaList));
        }
예제 #7
0
        public ActionResult GetEmployeeRepoManPendingLOAList()
        {
            LOAService loaService = new LOAService();

            List <LOA> loas = new List <LOA>();

            loas = loaService.GetReportingManagerPendingLOAs(User.Identity.GetUserId());

            var loaList = Mapper.Map <List <LOA>, List <LoaListViewModel> >(loas);

            ViewBag.TSRole = "TimeSheetReportingManager";

            return(PartialView("_EmployeePendingLOAList", loaList));
        }
예제 #8
0
        public async Task <ActionResult> EmployeeAdminLOAEdit([Bind(Exclude = "LookupLoaStatus,LoaCode")] LoaViewModel lvm, string action)
        {
            try
            {
                LOAService loaService = new LOAService();

                if (!ModelState.IsValid)
                {
                    lvm.TimeOfDayList   = GetDropDownList("LoaTimeOfDay", null);
                    lvm.TypeOfLeaveList = GetDropDownList("LoaTypeOfLeave", null);
                    return(View(lvm));
                }


                var loa = loaService.GetJustLOA(lvm.LoaId);
                if (loa == null)
                {
                    TempData["error"] = "LOA does not exist";
                    return(RedirectToAction("EmployeeAdminLOAList"));
                }
                loa.StartDate         = lvm.StartDate;
                loa.EndDate           = lvm.EndDate;
                loa.LookupTimeOfDay   = lvm.LookupTimeOfDay;
                loa.OtherTimeOfDay    = lvm.OtherTimeOfDay;
                loa.LookupTypeOfLeave = lvm.LookupTypeOfLeave;
                loa.OtherTypeOfLeave  = lvm.OtherTypeOfLeave;
                loa.ReasonForLeave    = lvm.ReasonForLeave;

                loa.ModifiedUserId = User.Identity.GetUserId();
                loa.ModifiedDate   = DateTime.Now;

                loaService.UpdateLOA(loa);
                ChangeStatusOfLOA(loa.LoaId, "Pending");

                TempData["status"] = "LOA " + loa.LoaCode + " successfully updated and status changed to pending ";

                return(RedirectToAction("EmployeeAdminLOAList"));
            }
            catch (Exception ex)
            {
                LOAService loaService = new LOAService();
                TempData["error"]          = "Something went wrong while editing LOA";
                lvm.TimeOfDayList          = GetDropDownList("LoaTimeOfDay", null);
                lvm.TypeOfLeaveList        = GetDropDownList("LoaTypeOfLeave", null);
                lvm.LookupOtherTimeOfDay   = loaService.GetLookupIdForCodeName("Other", "LoaTimeOfDay").LookupCodeId;
                lvm.LookupOtherTypeOfLeave = loaService.GetLookupIdForCodeName("Other", "LoaTypeOfLeave").LookupCodeId;
                return(RedirectToAction("EmployeeAdminLOAList"));
            }
        }
예제 #9
0
        public ActionResult HardDeleteMyLOA(int id)
        {
            try
            {
                LOAService loaService = new LOAService();

                loaService.HardDeleteLOA(id);

                TempData["status"] = "LOA successfully deleted";
                return(RedirectToAction("MyLOAList"));
            }
            catch
            {
                TempData["error"] = "Something went wrong while deleting LOA";
                return(RedirectToAction("MyLOAList"));
            }
        }
예제 #10
0
        public ActionResult MyLOAList()
        {
            if (TempData["error"] != null)
            {
                ViewBag.error = TempData["error"];
            }
            if (TempData["status"] != null)
            {
                ViewBag.status = TempData["status"];
            }


            LOAService loaService           = new LOAService();
            var        loas                 = loaService.GetLoaListWithUserId(User.Identity.GetUserId());
            List <LoaListViewModel> loaList = new List <LoaListViewModel>();

            loaList = Mapper.Map <List <LOA>, List <LoaListViewModel> >(loas);

            return(View(loaList));
        }
예제 #11
0
        public ActionResult MyLOACreate()
        {
            if (TempData["error"] != null)
            {
                ViewBag.error = TempData["error"];
            }
            if (TempData["status"] != null)
            {
                ViewBag.status = TempData["status"];
            }


            //string Employeename = HttpContext.User.Identity.Name;
            LoaViewModel lvm        = new LoaViewModel();
            LOAService   loaService = new LOAService();


            UserService userService = new UserService();

            lvm.UserId          = User.Identity.GetUserId();
            lvm.AspNetUser      = userService.GetUserWithId(lvm.UserId);
            lvm.TimeOfDayList   = GetDropDownList("LoaTimeOfDay", null);
            lvm.TypeOfLeaveList = GetDropDownList("LoaTypeOfLeave", null);

            lvm.LookupOtherTimeOfDay   = loaService.GetLookupIdForCodeName("Other", "LoaTimeOfDay").LookupCodeId;
            lvm.LookupOtherTypeOfLeave = loaService.GetLookupIdForCodeName("Other", "LoaTypeOfLeave").LookupCodeId;

            lvm.StartDate = DateTime.Now;
            lvm.EndDate   = DateTime.Now;
            if (lvm.AspNetUser.AspNetUser1 != null)
            {
                lvm.ReportingManager = lvm.AspNetUser.AspNetUser1.Firstname + " " + lvm.AspNetUser.AspNetUser1.LastName;
            }
            else
            {
                lvm.ReportingManager = "None";
            }


            return(View(lvm));
        }
예제 #12
0
        public ActionResult EmployeeManagerLOADetails(int id)
        {
            if (TempData["error"] != null)
            {
                ViewBag.error = TempData["error"];
            }
            if (TempData["status"] != null)
            {
                ViewBag.status = TempData["status"];
            }

            ViewBag.TSRole = "TimeSheetManager";
            // string Employeename = HttpContext.User.Identity.Name;
            LoaViewModel lvm        = new LoaViewModel();
            LOAService   loaService = new LOAService();
            var          loa        = loaService.GetLOA(id);

            if (loa == null)
            {
                TempData["error"] = "LOA does not exist";
                //return RedirectToAction("Index");
                return(RedirectToAction("EmployeeManagerLOAList"));
            }
            lvm = Mapper.Map <LOA, LoaViewModel>(loa);
            lvm.TimeOfDayList          = GetDropDownList("LoaTimeOfDay", null);
            lvm.TypeOfLeaveList        = GetDropDownList("LoaTypeOfLeave", null);
            lvm.LookupOtherTimeOfDay   = loaService.GetLookupIdForCodeName("Other", "LoaTimeOfDay").LookupCodeId;
            lvm.LookupOtherTypeOfLeave = loaService.GetLookupIdForCodeName("Other", "LoaTypeOfLeave").LookupCodeId;

            if (lvm.AspNetUser.AspNetUser1 != null)
            {
                lvm.ReportingManager = lvm.AspNetUser.AspNetUser1.Firstname + " " + lvm.AspNetUser.AspNetUser1.LastName;
            }
            else
            {
                lvm.ReportingManager = "None";
            }

            return(View("EmployeeLOADetails", lvm));
        }
예제 #13
0
        public ActionResult MyLOADetails(int id)
        {
            if (TempData["error"] != null)
            {
                ViewBag.error = TempData["error"];
            }
            if (TempData["status"] != null)
            {
                ViewBag.status = TempData["status"];
            }

            LoaViewModel lvm        = new LoaViewModel();
            LOAService   loaService = new LOAService();
            var          loa        = loaService.GetMyLOA(id, User.Identity.GetUserId());

            if (loa == null)
            {
                TempData["error"] = "LOA does not exist or you dont have permissions";
                return(RedirectToAction("MyLOAList"));
            }

            lvm = Mapper.Map <LOA, LoaViewModel>(loa);

            lvm.TimeOfDayList          = GetDropDownList("LoaTimeOfDay", null);
            lvm.TypeOfLeaveList        = GetDropDownList("LoaTypeOfLeave", null);
            lvm.LookupOtherTimeOfDay   = loaService.GetLookupIdForCodeName("Other", "LoaTimeOfDay").LookupCodeId;
            lvm.LookupOtherTypeOfLeave = loaService.GetLookupIdForCodeName("Other", "LoaTypeOfLeave").LookupCodeId;

            if (lvm.AspNetUser.AspNetUser1 != null)
            {
                lvm.ReportingManager = lvm.AspNetUser.AspNetUser1.Firstname + " " + lvm.AspNetUser.AspNetUser1.LastName;
            }
            else
            {
                lvm.ReportingManager = "None";
            }

            return(View(lvm));
        }
예제 #14
0
        public async Task SendEmailLOASubmitted(int LoaId, bool includeAttachment = false)
        {
            try
            {
                LOAService loaService = new LOAService();
                var        loa        = loaService.GetLOA(LoaId);

                var subject = "LOA from " + loa.AspNetUser.Firstname + " " + loa.AspNetUser.LastName;
                //var fileName = GetExcelFileName(timeSheet);
                var callbackUrl = Url.Action("EmployeeRepoManLOADetails", "LOA", new { id = LoaId }, protocol: Request.Url.Scheme);
                var body        = "Your Employee " + loa.AspNetUser.Firstname + " " + loa.AspNetUser.LastName + " submitted LOA with Id" + loa.LoaCode +
                                  " from " + loa.StartDate.ToString("MM/dd/yyyy") + "-" + loa.EndDate.ToString("MM/dd/yyyy") + "" +
                                  ", You can Approve/Reject it by clicking <a href=\"" + callbackUrl + "\">here</a>";

                //var destinationEmail = WebConfigurationManager.AppSettings["HREmail"];
                var             destinationEmail = loa.AspNetUser.AspNetUser1.Email;
                IdentityMessage im = CreateMessage(destinationEmail, subject, body);

                if (includeAttachment)
                {
                    //byte[] bytes = GetExcelByteDate(loa);
                    //await SendEmailWithAttachment(im, bytes, subject);
                    await SendEmailWithAttachment(im, null, null);
                }
                else
                {
                    await SendEmailWithAttachment(im, null, null);
                }


                TempData["status"] = "LOA submitted to your Reporting Manager";
            }
            catch (Exception ex)
            {
                TempData["error"] = "Something went wrong while sending email";
            }
        }
예제 #15
0
        public async Task SendEmailLOARejected(int LoaId, bool includeAttachment = false)
        {
            try
            {
                LOAService loaService = new LOAService();
                var        loa        = loaService.GetLOA(LoaId);

                var subject     = "LOA Rejected";
                var callbackUrl = Url.Action("MyLOAEdit", "LOA", new { id = LoaId }, protocol: Request.Url.Scheme);
                var body        = "Your LOA with Id " + loa.LoaCode + " from " + loa.StartDate.ToString("MM/dd/yyyy") + "-" + loa.EndDate.ToString("MM/dd/yyyy") + "" +
                                  "was rejected with comments '" + loa.Comments + "' please click <a href=\"" + callbackUrl + "\">here</a> to review LOA and submit agian";

                //var destinationEmail = WebConfigurationManager.AppSettings["HREmail"];
                var             destinationEmail = loa.AspNetUser.Email;
                IdentityMessage im = CreateMessage(destinationEmail, subject, body);

                if (includeAttachment)
                {
                    //byte[] bytes = GetExcelByteDate(timeSheet);
                    //await SendEmailWithAttachment(im, bytes, subject);
                    await SendEmailWithAttachment(im, null, null);
                }
                else
                {
                    await SendEmailWithAttachment(im, null, null);
                }


                TempData["status"] = "LOA rejection mail sent to employee";
                //return RedirectToAction("EmployeeTimeSheetsList");
            }
            catch (Exception ex)
            {
                TempData["error"] = "Something went wrong while sending rejection mail";
            }
        }
예제 #16
0
        public ActionResult Index()

        {
            List <DashboardViewModel> dashboardItems = new List <DashboardViewModel>();
            List <DashboardViewModel> items          = new List <DashboardViewModel>();
            var viewModel = new DashboardViewModels();

            SupportService   supportService   = new SupportService();
            TimeSheetService timesheetService = new TimeSheetService();
            ExpenseService   expenseService   = new ExpenseService();
            LOAService       loaService       = new LOAService();

            var roles = ((ClaimsIdentity)User.Identity).Claims
                        .Where(c => c.Type == ClaimTypes.Role)
                        .Select(c => c.Value);

            if (roles.Contains("TimeSheetAdmin"))
            {
                viewModel.AdminPendingExpensesCount   = expenseService.GetPendingExpensesCount();
                viewModel.AdminPendingLOAsCount       = loaService.GetPendingLOAsCount();
                viewModel.AdminPendingTimesheetsCount = timesheetService.GetPendingTimesheetsCount();

                //    viewModel.DasboardList.AddRange(ExpenseModuleAdmin());
            }
            else if (roles.Contains("TimeSheetManager"))
            {
                viewModel.ManagerPendingTimesheetsCount = timesheetService.GetPendingTimesheetsCount();
                viewModel.MangerPendingExpensesCount    = expenseService.GetPendingExpensesCount();
                viewModel.MangerPendingLOAsCount        = loaService.GetPendingLOAsCount();
                //    viewModel.DasboardList.AddRange(TimeSheetModuleManager());
                //    viewModel.DasboardList.AddRange(LOAModuleManager());
                //    items.AddRange(ExpenseModuleManager());
            }

            if (roles.Contains("TimeSheetReportingManager"))
            {
                viewModel.ReportingManagerPendingExpensesCount   = expenseService.GetPendingExpensesCount(User.Identity.GetUserId());
                viewModel.ReportingManagerPendingLOAsCount       = loaService.GetPendingLOAsCount(User.Identity.GetUserId());
                viewModel.ReportingManagerPendingTimesheetsCount = timesheetService.GetPendingTimesheetsCount(User.Identity.GetUserId());
                //    viewModel.DasboardList.AddRange(TimeSheetModuleReportingManager());
                //    viewModel.DasboardList.AddRange(LOAModuleReportingManager());
                //    viewModel.DasboardList.AddRange(ExpenseModuleReportingManager());
            }

            if (roles.Contains("SupportUser"))
            {
                //viewModel.DasboardList.AddRange(SupportModuleUserPendingRequest());
                //viewModel.DasboardList.AddRange(SupportModuleUserDoneRequest());
                //viewModel.DasboardList.AddRange(SupportModuleUserClosedRequest());
                viewModel.MyPendingRequestsCount = supportService.GetMyPendingRequestsCount(User.Identity.GetUserId());
                viewModel.MyClosedRequestsCount  = supportService.GetMyClosedRequestsCount(User.Identity.GetUserId());
                viewModel.MyDoneRequestsCount    = supportService.GetMyDoneRequestsCount(User.Identity.GetUserId());
            }



            //viewModel.DasboardList.AddRange(items);

            //dashboardItems.AddRange(items);

            return(View(viewModel));
        }
예제 #17
0
        public async Task <ActionResult> MyLOACreate([Bind(Exclude = "LookupLoaStatus,LoaCode")] LoaViewModel lvm, string action)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    lvm.TimeOfDayList   = GetDropDownList("LoaTimeOfDay", null);
                    lvm.TypeOfLeaveList = GetDropDownList("LoaTypeOfLeave", null);
                    return(View(lvm));
                }
                //else if(tsvm.TotalHours <= 0 || tsvm.TotalHours == null)
                //{
                //    ModelState.AddModelError("error", "Total Hours cannot be less than or equal to 0");
                //    tsvm.AbsenceTypeList = GetDropDownList("Absence", null);
                //    return View(tsvm);
                //}

                LOA        loa        = new LOA();
                LOAService loaService = new LOAService();

                loa = Mapper.Map <LoaViewModel, LOA>(lvm);


                //loa.UserId = lvm.UserId;
                //loa.StartDate = lvm.StartDate;
                //loa.EndDate = lvm.EndDate;
                loa.AspNetUser = null;
                UserService userService = new UserService();
                var         user        = userService.GetUserWithId(lvm.UserId);
                var         repoMan     = user.AspNetUser1;


                loa.IsActive        = true;
                loa.IsDeleted       = false;
                loa.CreatedUserId   = User.Identity.GetUserId();
                loa.CreatedDate     = DateTime.Now;
                loa.ModifiedUserId  = User.Identity.GetUserId();
                loa.ModifiedDate    = DateTime.Now;
                loa.LookupLoaStatus = loaService.GetLookupIdForCodeName("Saved", "LoaStatus").LookupCodeId;


                loaService.CreateLoa(loa);


                if (string.Equals(action.ToString(), "Submit"))
                {
                    if (repoMan != null)
                    {
                        ChangeStatusOfLOA(loa.LoaId, "Pending");
                        await SendEmailLOASubmitted(loa.LoaId);

                        TempData["status"] = "LOA " + loa.LoaCode + " successfully saved and submitted to your reporting manager";
                    }

                    else
                    {
                        TempData["status"] = "Your LOA is saved but not submitted. You do not have a reporting manager assigned. Please contact your admin.";
                    }
                }


                return(RedirectToAction("MyLOAList"));
            }


            catch (Exception ex)
            {
                LOAService loaService = new LOAService();
                lvm.TimeOfDayList          = GetDropDownList("LoaTimeOfDay", null);
                lvm.TypeOfLeaveList        = GetDropDownList("LoaTypeOfLeave", null);
                TempData["error"]          = "Something went wrong while saving LOA";
                lvm.LookupOtherTimeOfDay   = loaService.GetLookupIdForCodeName("Other", "LoaTimeOfDay").LookupCodeId;
                lvm.LookupOtherTypeOfLeave = loaService.GetLookupIdForCodeName("Other", "LoaTypeOfLeave").LookupCodeId;
                return(RedirectToAction("MyLOAList"));
            }
        }
예제 #18
0
        public async Task <ActionResult> MyLOAEdit([Bind(Exclude = "LookupLoaStatus,LoaCode")] LoaViewModel lvm, string action)
        {
            try
            {
                LOAService loaService = new LOAService();

                if (!ModelState.IsValid)
                {
                    lvm.TimeOfDayList   = GetDropDownList("LoaTimeOfDay", null);
                    lvm.TypeOfLeaveList = GetDropDownList("LoaTypeOfLeave", null);
                    return(View(lvm));
                }

                //var loa = Mapper.Map<LoaViewModel, LOA>(lvm);
                var loa = loaService.GetJustMyLOA(lvm.LoaId, User.Identity.GetUserId());
                if (loa == null)
                {
                    TempData["error"] = "LOA does not exist";
                    return(RedirectToAction("MyLOAList"));
                }
                loa.StartDate         = lvm.StartDate;
                loa.EndDate           = lvm.EndDate;
                loa.LookupTimeOfDay   = lvm.LookupTimeOfDay;
                loa.OtherTimeOfDay    = lvm.OtherTimeOfDay;
                loa.LookupTypeOfLeave = lvm.LookupTypeOfLeave;
                loa.OtherTypeOfLeave  = lvm.OtherTypeOfLeave;
                loa.ReasonForLeave    = lvm.ReasonForLeave;


                loa.ModifiedUserId = User.Identity.GetUserId();
                loa.ModifiedDate   = DateTime.Now;

                loaService.UpdateLOA(loa);


                UserService userService = new UserService();
                var         user        = userService.GetUserWithId(lvm.UserId);
                var         repoMan     = user.AspNetUser1;

                TempData["status"] = "LOA successfully updated";

                if (string.Equals(action.ToString(), "Submit"))
                {
                    if (repoMan != null)
                    {
                        ChangeStatusOfLOA(loa.LoaId, "Pending");
                        await SendEmailLOASubmitted(loa.LoaId);

                        TempData["status"] = "LOA " + loa.LoaCode + " successfully saved and submitted to your reporting manager";
                    }

                    else
                    {
                        TempData["status"] = "Your LOA is saved but not submitted. You do not have a reporting manager assigned. Please contact your admin.";
                    }
                }

                return(RedirectToAction("MyLOAList"));
            }
            catch (Exception ex)
            {
                LOAService loaService = new LOAService();
                TempData["error"]          = "Something went wrong while editing LOA";
                lvm.TimeOfDayList          = GetDropDownList("LoaTimeOfDay", null);
                lvm.TypeOfLeaveList        = GetDropDownList("LoaTypeOfLeave", null);
                lvm.LookupOtherTimeOfDay   = loaService.GetLookupIdForCodeName("Other", "LoaTimeOfDay").LookupCodeId;
                lvm.LookupOtherTypeOfLeave = loaService.GetLookupIdForCodeName("Other", "LoaTypeOfLeave").LookupCodeId;
                return(RedirectToAction("MyLOAList"));
            }
        }