示例#1
0
        public async Task <ActionResult> SaveLeaveStatus()
        {
            try
            {
                string UnParse = Request.Form["hdnLeaveStatus"].ToString();
                Dictionary <int, int> StatusList = new Dictionary <int, int>();
                List <string>         tempstr    = new List <string>();
                tempstr = UnParse.Split(',').ToList();
                foreach (string item in tempstr)
                {
                    string data;
                    data = item.Trim('(');
                    data = data.Trim(')');
                    StatusList.Add(int.Parse(data.Split('|').ToArray()[0]), int.Parse(data.Split('|').ToArray()[1]));
                }

                foreach (var item in StatusList)
                {
                    try
                    {
                        LeaveRequestEntity ob = new LeaveRequestEntity();
                        ob               = LeaveServices.GetLeaveByRequestId(item.Key);
                        ob.RequestId     = item.Key;
                        ob.LeaveStatusId = item.Value;
                        ob.UpdatedBy     = HRMHelper.CurrentUser.UserId;
                        LeaveServices.InsertUpdateLeave(ob);
                        if (item.Value != (int)LeaveServices.Leave_status_Type.PendingApproval)
                        {
                            string Heading     = GetHeading(item.Value);
                            string MailMessage = "Your " + Heading + " from " + ob.StartTime.ToString("MM/dd/yy") + " to " + ob.EndTime.ToString("MM/dd/yy");
                            try
                            {
                                string    CCMail  = AppSettings.HRMail;
                                ArrayList Urltext = new ArrayList();
                                ArrayList Urls    = new ArrayList();
                                Urltext.Add("Click Here to check status");
                                Urls.Add(AppSettings.SiteURL + Url.Action("LeaveRecords", "Leave"));
                                UserEntity tempUser = UserServices.GetUserByID(ob.UserId);
                                await MailUtil.MailSend(Heading, tempUser.Name, MailMessage, Urltext, Urls, tempUser.Email, CCMail, Heading);
                            }
                            catch
                            { }
                        }
                    }
                    catch
                    { }
                }
                TempData[HRMWeb.Helpers.AlertStyles.Success] = "Leave Status Updated Successfully.";
            }
            catch
            { }
            return(RedirectToAction("LeaveRecords", "Leave"));
        }