Esempio n. 1
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"));
            }
        }
Esempio n. 2
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));
        }
Esempio n. 3
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";
            }
        }
Esempio n. 4
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";
            }
        }