public async Task <ActionResult> Editing_Update(DataSourceRequest request, NewEntryByProjectSelection[] MODEL)
        {
            ViewBag.ProjectList  = DropdownList.ProjectList((long)Session[Constants.SessionEmpID], (long)(Session[Constants.SessionRoleID]));
            ViewBag.EmployeeList = DropdownList.EmployeeList();
            ViewBag.Quadrent     = GetQuardrent();
            if (MODEL != null)
            {
                try
                {
                    long   _entryId     = (long)Session[Constants.SessionEmpID];
                    string quarter      = MODEL.Any() ? MODEL[0].Quarter : GetQuarter();
                    var    listMonth    = (from Quart in DB.Quarter where Quart.Quarter == quarter select new { Quart.Month }).ToList();
                    string month1       = DateTime.Now.ToString("yyyy/" + listMonth[0].Month + "/01");
                    string month2       = DateTime.Now.ToString("yyyy/" + listMonth[1].Month + "/01");
                    string month3       = DateTime.Now.ToString("yyyy/" + listMonth[2].Month + "/01");
                    int    currentmonth = GetQuarter() == quarter ? DateTime.Now.Month : Convert.ToInt32(listMonth[2].Month);
                    List <KeyValuePair <string, string> > emailStatus = new List <KeyValuePair <string, string> >();
                    if (MODEL != null && ModelState.IsValid)
                    {
                        foreach (NewEntryByProjectSelection product in MODEL)
                        {
                            int _currentNumber     = 0;
                            IQueryable <int> items = DB.EmpTimeSheet.OrderByDescending(u => u.SequenceNo).Take(1).Select(e => e.SequenceNo);
                            foreach (int ir in items)
                            {
                                _currentNumber = ir;
                            }
                            if (_currentNumber == 0)
                            {
                                _currentNumber = 100;
                            }
                            else
                            {
                                _currentNumber++;
                            }
                            if (currentmonth == Convert.ToInt32(listMonth[0].Month))
                            {
                                NewEntryModel newEntryModel = new NewEntryModel();
                                newEntryModel.InvolveMonth   = Convert.ToDateTime(month1);
                                newEntryModel.DaysCount      = Convert.ToDecimal(product.InvolvementDays1);
                                newEntryModel.DaysEditCount  = Convert.ToDecimal(product.InvolvementEditDays1);
                                newEntryModel.InvolvePercent = CalculateInvolvementPercentage(product.EmployeeID, product.InvolvementEditDays1, newEntryModel);
                                NewEntryModel exists = DB.EmpTimeSheet.FirstOrDefault(x => x.InvolveMonth == newEntryModel.InvolveMonth && x.EmpId == product.EmployeeID && x.ProjectID == product.ProjectID);

                                if (exists != null)
                                {
                                    newEntryModel.TsID                  = exists.TsID;
                                    newEntryModel.RefNo                 = exists.RefNo;
                                    newEntryModel.SequenceNo            = exists.SequenceNo;
                                    newEntryModel.EntryBy               = (long)Session[Constants.SessionEmpID]; //empid
                                    newEntryModel.EntryDate             = DateTime.Now;
                                    newEntryModel.Quart                 = quarter;
                                    newEntryModel.EntryRole             = (long)Session[Constants.SessionRoleID];
                                    newEntryModel.EmpId                 = product.EmployeeID; //empid
                                    newEntryModel.ProjectID             = product.ProjectID;
                                    newEntryModel.EmpRemarks            = "";
                                    newEntryModel.ApproveRejectComments = "";
                                    newEntryModel.ApproveRejectStatus   = "A";
                                    newEntryModel.ApproveRejectUser     = (long)Session[Constants.SessionEmpID];
                                    newEntryModel.ApproveRejectDate     = DateTime.Now;
                                    newEntryModel.Status                = Convert.ToInt64(ReadConfig.GetValue("StatusApproved"));
                                    DB.Entry(exists).CurrentValues.SetValues(newEntryModel);
                                    DB.SaveChanges();
                                }
                                else
                                {
                                    if (newEntryModel.DaysEditCount != 0 || product.IsEdit1)

                                    {
                                        newEntryModel.RefNo                 = AutoGen.GetReferenceNumber();
                                        newEntryModel.SequenceNo            = _currentNumber;
                                        newEntryModel.EntryBy               = _entryId; //empid
                                        newEntryModel.EntryDate             = DateTime.Now;
                                        newEntryModel.EntryRole             = (long)Session[Constants.SessionRoleID];
                                        newEntryModel.EmpId                 = product.EmployeeID; //empid
                                        newEntryModel.ProjectID             = product.ProjectID;
                                        newEntryModel.Quart                 = quarter;
                                        newEntryModel.EmpRemarks            = "";
                                        newEntryModel.ApproveRejectComments = "";
                                        newEntryModel.ApproveRejectStatus   = "A";
                                        newEntryModel.ApproveRejectUser     = (long)Session[Constants.SessionEmpID];
                                        newEntryModel.ApproveRejectDate     = DateTime.Now;
                                        newEntryModel.Status                = Convert.ToInt64(ReadConfig.GetValue("StatusApproved"));
                                        DB.EmpTimeSheet.Add(newEntryModel);
                                        DB.SaveChanges();
                                    }
                                }
                            }
                            if (currentmonth == Convert.ToInt32(listMonth[1].Month))
                            {
                                foreach (string month in months)
                                {
                                    NewEntryModel newEntryModel = new NewEntryModel();
                                    bool          isEdit        = false;
                                    if (month == months[0])
                                    {
                                        newEntryModel.InvolveMonth   = Convert.ToDateTime(month1);
                                        newEntryModel.DaysCount      = Convert.ToDecimal(product.InvolvementDays1);
                                        newEntryModel.DaysEditCount  = Convert.ToDecimal(product.InvolvementEditDays1);
                                        newEntryModel.InvolvePercent = CalculateInvolvementPercentage(product.EmployeeID, product.InvolvementEditDays1, newEntryModel);
                                        isEdit = product.IsEdit1;
                                    }
                                    if (month == months[1])
                                    {
                                        newEntryModel.InvolveMonth   = Convert.ToDateTime(month2);
                                        newEntryModel.DaysCount      = Convert.ToDecimal(product.InvolvementDays2);
                                        newEntryModel.DaysEditCount  = Convert.ToDecimal(product.InvolvementEditDays2);
                                        newEntryModel.InvolvePercent = CalculateInvolvementPercentage(product.EmployeeID, product.InvolvementEditDays2, newEntryModel);
                                        isEdit = product.IsEdit2;
                                    }
                                    if (newEntryModel.DaysEditCount != 0 || isEdit)
                                    {
                                        NewEntryModel exists = DB.EmpTimeSheet.FirstOrDefault(x => x.InvolveMonth == newEntryModel.InvolveMonth && x.EmpId == product.EmployeeID && x.ProjectID == product.ProjectID);
                                        if (ModelState.IsValid)
                                        {
                                            if (exists != null)
                                            {
                                                newEntryModel.TsID                  = exists.TsID;
                                                newEntryModel.RefNo                 = exists.RefNo;
                                                newEntryModel.SequenceNo            = exists.SequenceNo;
                                                newEntryModel.EntryBy               = (long)Session[Constants.SessionEmpID]; //empid
                                                newEntryModel.EntryDate             = DateTime.Now;
                                                newEntryModel.Quart                 = quarter;
                                                newEntryModel.EntryRole             = (long)Session[Constants.SessionRoleID];
                                                newEntryModel.EmpId                 = product.EmployeeID; //empid
                                                newEntryModel.ProjectID             = product.ProjectID;
                                                newEntryModel.EmpRemarks            = "";
                                                newEntryModel.ApproveRejectComments = "";
                                                newEntryModel.ApproveRejectStatus   = "A";
                                                newEntryModel.ApproveRejectUser     = (long)Session[Constants.SessionEmpID];
                                                newEntryModel.ApproveRejectDate     = DateTime.Now;
                                                newEntryModel.Status                = Convert.ToInt64(ReadConfig.GetValue("StatusApproved"));
                                                DB.Entry(exists).CurrentValues.SetValues(newEntryModel);
                                                DB.SaveChanges();
                                            }
                                            else
                                            {
                                                newEntryModel.RefNo                 = AutoGen.GetReferenceNumber();
                                                newEntryModel.SequenceNo            = _currentNumber;
                                                newEntryModel.EntryBy               = _entryId; //empid
                                                newEntryModel.EntryDate             = DateTime.Now;
                                                newEntryModel.EntryRole             = (long)Session[Constants.SessionRoleID];
                                                newEntryModel.EmpId                 = product.EmployeeID; //empid
                                                newEntryModel.ProjectID             = product.ProjectID;
                                                newEntryModel.Quart                 = quarter;
                                                newEntryModel.EmpRemarks            = "";
                                                newEntryModel.ApproveRejectComments = "";
                                                newEntryModel.ApproveRejectStatus   = "A";
                                                newEntryModel.ApproveRejectUser     = (long)Session[Constants.SessionEmpID];
                                                newEntryModel.ApproveRejectDate     = DateTime.Now;
                                                newEntryModel.Status                = Convert.ToInt64(ReadConfig.GetValue("StatusApproved"));

                                                DB.EmpTimeSheet.Add(newEntryModel);
                                                DB.SaveChanges();
                                            }
                                        }
                                        else
                                        {
                                            TempData["Error"] = ResourceMessage.DayscountExceed;
                                            //return View("Index", BindData(model.QID));
                                        }
                                    }
                                }
                            }
                            if (currentmonth == Convert.ToInt32(listMonth[2].Month))
                            {
                                foreach (string month in months)
                                {
                                    NewEntryModel newEntryModel = new NewEntryModel();
                                    bool          isEdit        = false;
                                    if (month == months[0])
                                    {
                                        newEntryModel.InvolveMonth   = Convert.ToDateTime(month1);
                                        newEntryModel.DaysCount      = Convert.ToDecimal(product.InvolvementDays1);
                                        newEntryModel.DaysEditCount  = Convert.ToDecimal(product.InvolvementEditDays1);
                                        newEntryModel.InvolvePercent = CalculateInvolvementPercentage(product.EmployeeID, product.InvolvementEditDays1, newEntryModel);
                                        isEdit = product.IsEdit1;
                                    }
                                    if (month == months[1])
                                    {
                                        newEntryModel.InvolveMonth   = Convert.ToDateTime(month2);
                                        newEntryModel.DaysCount      = Convert.ToDecimal(product.InvolvementDays2);
                                        newEntryModel.DaysEditCount  = Convert.ToDecimal(product.InvolvementEditDays2);
                                        newEntryModel.InvolvePercent = CalculateInvolvementPercentage(product.EmployeeID, product.InvolvementEditDays2, newEntryModel);
                                        isEdit = product.IsEdit2;
                                    }
                                    if (month == months[2])
                                    {
                                        newEntryModel.InvolveMonth   = Convert.ToDateTime(month3);
                                        newEntryModel.DaysCount      = Convert.ToDecimal(product.InvolvementDays3);
                                        newEntryModel.DaysEditCount  = Convert.ToDecimal(product.InvolvementEditDays3);
                                        newEntryModel.InvolvePercent = CalculateInvolvementPercentage(product.EmployeeID, product.InvolvementEditDays3, newEntryModel);
                                        isEdit = product.IsEdit3;
                                    }

                                    if (newEntryModel.DaysEditCount != 0 || isEdit)
                                    {
                                        NewEntryModel exists = DB.EmpTimeSheet.FirstOrDefault(x => x.InvolveMonth == newEntryModel.InvolveMonth && x.EmpId == product.EmployeeID && x.ProjectID == product.ProjectID);
                                        if (ModelState.IsValid)
                                        {
                                            if (exists != null)
                                            {
                                                newEntryModel.TsID                  = exists.TsID;
                                                newEntryModel.RefNo                 = exists.RefNo;
                                                newEntryModel.SequenceNo            = exists.SequenceNo;
                                                newEntryModel.EntryBy               = (long)Session[Constants.SessionEmpID]; //empid
                                                newEntryModel.EntryDate             = DateTime.Now;
                                                newEntryModel.Quart                 = quarter;
                                                newEntryModel.EntryRole             = (long)Session[Constants.SessionRoleID];
                                                newEntryModel.EmpId                 = product.EmployeeID; //empid
                                                newEntryModel.ProjectID             = product.ProjectID;
                                                newEntryModel.EmpRemarks            = "";
                                                newEntryModel.ApproveRejectComments = "";
                                                newEntryModel.ApproveRejectStatus   = "A";
                                                newEntryModel.ApproveRejectUser     = (long)Session[Constants.SessionEmpID];
                                                newEntryModel.ApproveRejectDate     = DateTime.Now;
                                                newEntryModel.Status                = Convert.ToInt64(ReadConfig.GetValue("StatusApproved"));
                                                DB.Entry(exists).CurrentValues.SetValues(newEntryModel);
                                                DB.SaveChanges();
                                            }
                                            else
                                            {
                                                newEntryModel.RefNo                 = AutoGen.GetReferenceNumber();
                                                newEntryModel.SequenceNo            = _currentNumber;
                                                newEntryModel.EntryBy               = _entryId; //empid
                                                newEntryModel.EntryDate             = DateTime.Now;
                                                newEntryModel.EntryRole             = (long)Session[Constants.SessionRoleID];
                                                newEntryModel.EmpId                 = product.EmployeeID; //empid
                                                newEntryModel.ProjectID             = product.ProjectID;
                                                newEntryModel.Quart                 = quarter;
                                                newEntryModel.EmpRemarks            = "";
                                                newEntryModel.ApproveRejectComments = "";
                                                newEntryModel.ApproveRejectStatus   = "A";
                                                newEntryModel.ApproveRejectUser     = (long)Session[Constants.SessionEmpID];
                                                newEntryModel.ApproveRejectDate     = DateTime.Now;
                                                newEntryModel.Status                = Convert.ToInt64(ReadConfig.GetValue("StatusApproved"));
                                                DB.EmpTimeSheet.Add(newEntryModel);
                                                DB.SaveChanges();
                                            }
                                        }
                                        else
                                        {
                                            TempData["Error"] = ResourceMessage.DayscountExceed;
                                            //return View("Index", BindData(model.QID));
                                        }
                                    }
                                }
                            }

                            if ((product.IsEdit1 && product.InvolvementEditDays1 > 0) || (product.IsEdit2 && product.InvolvementEditDays2 > 0) || (product.IsEdit3 && product.InvolvementEditDays3 > 0))
                            {
                                var SubmittedMonths = new List <string>();
                                if (product.IsEdit1 && product.InvolvementEditDays1 > 0)
                                {
                                    SubmittedMonths.Add(product.Month1 + " " + Convert.ToDateTime(month1).Year);
                                }
                                if (product.IsEdit2 && product.InvolvementEditDays2 > 0)
                                {
                                    SubmittedMonths.Add(product.Month2 + " " + Convert.ToDateTime(month2).Year);
                                }
                                if (product.IsEdit3 && product.InvolvementEditDays3 > 0)
                                {
                                    SubmittedMonths.Add(product.Month3 + " " + Convert.ToDateTime(month3).Year);
                                }

                                string projectName     = DB.ProjectMaster.FirstOrDefault(x => x.ProjectID == product.ProjectID).ProjectName;
                                var    projectManagers = (from x in DB.ProjectEmployee.Where(x => x.ProjectID == product.ProjectID && x.EmployeeID != product.EmployeeID && x.CheckRole)
                                                          join y in DB.Employee on x.EmployeeID equals y.EmployeeID
                                                          join z in DB.User on y.UserID equals z.UserID
                                                          select new { z.Email, y.EmpFirstName, y.EmpLastName, y.EmpMiddleName }).ToList <dynamic>();
                                if (SubmittedMonths.Any() && projectManagers.Any())
                                {
                                    var emp      = DB.Employee.FirstOrDefault(x => x.EmployeeID == product.EmployeeID);
                                    var emailObj = new TimeSheetSubmissionEmailModel()
                                    {
                                        EmpName         = Models.Common.GetName(emp.EmpFirstName, emp.EmpLastName, emp.EmpMiddleName),
                                        ManagerInfo     = projectManagers,
                                        ProjectName     = projectName,
                                        SubmissionDates = string.Join(", ", SubmittedMonths)
                                    };
                                    bool emailResult = await Email.SendTimeSubmissionEmail(emailObj);

                                    if (!emailResult)
                                    {
                                        emailStatus.Add(new KeyValuePair <string, string>(emailObj.EmpName, projectName));
                                    }
                                }
                            }
                        }
                    }

                    return(Json(new { MODEL, emailStatus }));
                }
                catch (Exception ex)
                {
                    LogHelper.ErrorLog(ex);
                    throw ex;
                }
            }
            else
            {
                ViewBag.Quadrent = GetQuardrent();
                long empId = (long)Session[Constants.SessionEmpID];
                ViewBag.QuarterList = DropdownList.PreviousAndQuarterListNewEntryOnBehalf(empId);

                NewEntryByProjectSelection model = new NewEntryByProjectSelection
                {
                    Quarter = ViewBag.Quadrent,
                    Month1  = "Jan-2019"
                };
                return(View("Index", model));
            }
        }
        public async Task <ActionResult> Submit(NewEntryBox model)
        {
            long          _empId      = (long)Session[Constants.SessionEmpID];
            string        _empName    = Session[Constants.SessionEmpName].ToString();
            List <string> emailStatus = new List <string>();

            try
            {
                decimal edit1 = 0;
                decimal edit2 = 0;
                decimal edit3 = 0;
                model.Items[model.Items.Count - 1].InvolvementEditDays1 = 0;
                model.Items[model.Items.Count - 1].InvolvementEditDays2 = 0;
                model.Items[model.Items.Count - 1].InvolvementEditDays3 = 0;
                for (int i = 0; i < model.Items.Count - 1; i++)
                {
                    edit1 = edit1 + model.Items[i].InvolvementEditDays1;
                    edit2 = edit2 + model.Items[i].InvolvementEditDays2;
                    edit3 = edit3 + model.Items[i].InvolvementEditDays3;
                }
                model.Items[model.Items.Count - 1].InvolvementEditDays1 = edit1;
                model.Items[model.Items.Count - 1].InvolvementEditDays2 = edit2;
                model.Items[model.Items.Count - 1].InvolvementEditDays3 = edit3;

                if (Convert.ToDouble(model.Items[model.Items.Count - 1].InvolvementDays1) < Convert.ToDouble(model.Items[model.Items.Count - 1].InvolvementEditDays1) || Convert.ToDouble(model.Items[model.Items.Count - 1].InvolvementDays2) < Convert.ToDouble(model.Items[model.Items.Count - 1].InvolvementEditDays2) || Convert.ToDouble(model.Items[model.Items.Count - 1].InvolvementDays3) < Convert.ToDouble(model.Items[model.Items.Count - 1].InvolvementEditDays3))
                {
                    ViewBag.ErrorMessage = "Total Input is more than allowable days, Please adjust your timesheet";
                    ViewBag.QuarterList  = model.QID;
                    ViewBag.QuarterList  = DropdownList.PreviousAndQuarterList(_empId, true);
                    return(View("Index", BindData(model.QID)));
                }

                if (model != null)
                {
                    int roleId = Convert.ToInt32(Session[Constants.SessionRoleID]);
                    foreach (BoxItems item in model.Items.Where(x => x.IsEdit1 || x.IsEdit2 || x.IsEdit3))
                    {
                        if (item.ProjectID != 0)
                        {
                            int _currentNumber     = 0;
                            IQueryable <int> items = DB.EmpTimeSheet.OrderByDescending(u => u.SequenceNo).Take(1).Select(e => e.SequenceNo);
                            foreach (int ir in items)
                            {
                                _currentNumber = ir;
                            }
                            if (_currentNumber == 0)
                            {
                                _currentNumber = 100;
                            }
                            else
                            {
                                _currentNumber++;
                            }

                            foreach (string month in months)
                            {
                                bool          isEditable    = false;
                                NewEntryModel newEntryModel = new NewEntryModel();

                                newEntryModel.ApproveRejectStatus = roleId == 1 ? "A" : DB.ProjectEmployee.FirstOrDefault(x => x.EmployeeID == _empId && x.ProjectID == item.ProjectID).CheckRole == true ? "A" : null;
                                if (month == months[0])
                                {
                                    newEntryModel.InvolveMonth   = Convert.ToDateTime(model.Month1);
                                    newEntryModel.DaysCount      = item.InvolvementDays1;
                                    newEntryModel.DaysEditCount  = item.InvolvementEditDays1;
                                    newEntryModel.InvolvePercent = CalculateInvolvementPercentage(_empId, item.InvolvementEditDays1, newEntryModel);
                                    if (item.IsEdit1)
                                    {
                                        isEditable = true;
                                    }
                                }
                                if (month == months[1])
                                {
                                    newEntryModel.InvolveMonth   = Convert.ToDateTime(model.Month2);
                                    newEntryModel.DaysCount      = item.InvolvementDays2;
                                    newEntryModel.DaysEditCount  = item.InvolvementEditDays2;
                                    newEntryModel.InvolvePercent = CalculateInvolvementPercentage(_empId, item.InvolvementEditDays2, newEntryModel);
                                    if (item.IsEdit2)
                                    {
                                        isEditable = true;
                                    }
                                }
                                if (month == months[2])
                                {
                                    newEntryModel.InvolveMonth   = Convert.ToDateTime(model.Month3);
                                    newEntryModel.DaysCount      = item.InvolvementDays3;
                                    newEntryModel.DaysEditCount  = item.InvolvementEditDays3;
                                    newEntryModel.InvolvePercent = CalculateInvolvementPercentage(_empId, item.InvolvementEditDays3, newEntryModel);
                                    if (item.IsEdit3)
                                    {
                                        isEditable = true;
                                    }
                                }
                                if (newEntryModel.DaysCount != 0)
                                {
                                    if (isEditable)
                                    {
                                        NewEntryModel exists = DB.EmpTimeSheet.FirstOrDefault(x => x.InvolveMonth == newEntryModel.InvolveMonth && x.EmpId == _empId && x.ProjectID == item.ProjectID);
                                        if (exists != null)
                                        {
                                            newEntryModel.TsID       = exists.TsID;
                                            newEntryModel.RefNo      = exists.RefNo;
                                            newEntryModel.SequenceNo = exists.SequenceNo;
                                            newEntryModel.EntryBy    = _empId; //empid
                                            newEntryModel.EntryDate  = DateTime.Now;
                                            newEntryModel.Quart      = model.QID;
                                            newEntryModel.EntryRole  = (long)Session[Constants.SessionRoleID];
                                            newEntryModel.EmpId      = _empId; //empid
                                            newEntryModel.ProjectID  = item.ProjectID;
                                            newEntryModel.EmpRemarks = "";
                                            newEntryModel.Status     = newEntryModel.ApproveRejectStatus == "A" ? Convert.ToInt64(ReadConfig.GetValue("StatusApproved")) : Convert.ToInt64(ReadConfig.GetValue("StatusPending"));
                                            if (newEntryModel.ApproveRejectStatus == "A")
                                            {
                                                newEntryModel.ApproveRejectUser = _empId;
                                            }
                                            DB.Entry(exists).CurrentValues.SetValues(newEntryModel);
                                        }
                                        else
                                        {
                                            newEntryModel.RefNo      = AutoGen.GetReferenceNumber();
                                            newEntryModel.SequenceNo = _currentNumber;
                                            newEntryModel.EntryBy    = _empId; //empid
                                            newEntryModel.EntryDate  = DateTime.Now;
                                            newEntryModel.Quart      = model.QID;
                                            newEntryModel.EntryRole  = (long)Session[Constants.SessionRoleID];
                                            newEntryModel.EmpId      = _empId; //empid
                                            newEntryModel.ProjectID  = item.ProjectID;
                                            newEntryModel.EmpRemarks = "";
                                            newEntryModel.Status     = newEntryModel.ApproveRejectStatus == "A" ? Convert.ToInt64(ReadConfig.GetValue("StatusApproved")) : Convert.ToInt64(ReadConfig.GetValue("StatusPending"));
                                            if (newEntryModel.ApproveRejectStatus == "A")
                                            {
                                                newEntryModel.ApproveRejectUser = _empId;
                                            }
                                            DB.EmpTimeSheet.Add(newEntryModel);
                                        }
                                        DB.SaveChanges();

                                        if (newEntryModel.Status == Convert.ToInt64(ReadConfig.GetValue("StatusApproved")))
                                        {
                                            TempData["Success"] = ResourceMessage.NewEntryApprove;
                                        }
                                        else if (newEntryModel.Status == Convert.ToInt64(ReadConfig.GetValue("StatusPending")))
                                        {
                                            TempData["Success"] = ResourceMessage.NewEntrySubmit;
                                        }
                                    }
                                }
                            }

                            if ((item.InvolvementDays1 > 0 && item.InvolvementEditDays1 > 0) || (item.InvolvementDays2 > 0 && item.InvolvementEditDays2 > 0) || (item.InvolvementDays3 > 0 && item.InvolvementEditDays3 > 0))
                            {
                                var SubmittedMonths = new List <string>();
                                if (item.IsEdit1 && item.InvolvementEditDays1 > 0)
                                {
                                    SubmittedMonths.Add(model.Month1);
                                }
                                if (item.IsEdit2 && item.InvolvementEditDays2 > 0)
                                {
                                    SubmittedMonths.Add(model.Month2);
                                }
                                if (item.IsEdit3 && item.InvolvementEditDays3 > 0)
                                {
                                    SubmittedMonths.Add(model.Month3);
                                }
                                if (roleId != 1)
                                {
                                    bool isProjectManager = DB.ProjectEmployee.FirstOrDefault(x => x.ProjectID == item.ProjectID && x.EmployeeID == _empId).CheckRole;
                                    if (!isProjectManager)
                                    {
                                        string projectName     = DB.ProjectMaster.FirstOrDefault(x => x.ProjectID == item.ProjectID).ProjectName;
                                        var    projectManagers = (from x in DB.ProjectEmployee.Where(x => x.ProjectID == item.ProjectID && x.EmployeeID != _empId && x.CheckRole)
                                                                  join y in DB.Employee on x.EmployeeID equals y.EmployeeID
                                                                  join z in DB.User on y.UserID equals z.UserID
                                                                  select new { z.Email, y.EmpFirstName, y.EmpLastName, y.EmpMiddleName }).ToList <dynamic>();
                                        if (SubmittedMonths.Any() && projectManagers.Any())
                                        {
                                            bool emailResult = await Email.SendTimeSubmissionEmail(new TimeSheetSubmissionEmailModel()
                                            {
                                                EmpName         = _empName,
                                                ManagerInfo     = projectManagers,
                                                ProjectName     = projectName,
                                                SubmissionDates = string.Join(", ", SubmittedMonths)
                                            });

                                            if (!emailResult)
                                            {
                                                emailStatus.Add(projectName);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TempData["Error"] = ex.ToString();
                LogHelper.ErrorLog(ex);
            }
            // TempData["EmailNotificationErrors"] = emailStatus;
            return(RedirectToAction("Index"));
        }