//SendMail
        public ActionResult SendMailToAll(string Compltiondate)
        {
            PerformanceSettingViewModel model = new PerformanceSettingViewModel();
            var ToData   = _db.AspNetUsers.Where(x => x.SSOID.StartsWith("W") && x.Archived == false).ToList();
            var FromData = _db.AspNetUsers.Where(x => x.Id == SessionProxy.UserId).FirstOrDefault();

            if (!string.IsNullOrEmpty(Compltiondate))
            {
                foreach (var item in ToData)
                {
                    HRTool.Models.MailModel mail = new HRTool.Models.MailModel();
                    mail.From    = FromData.UserName;
                    mail.To      = item.UserName;
                    mail.Subject = "Performance Review";
                    mail.Header  = "Performance Review";
                    string   inputFormat      = "dd-MM-yyyy";
                    string   outputFormat     = "ddd, dd MMM yyyy";
                    var      VarCompetiondate = DateTime.ParseExact(Compltiondate, inputFormat, CultureInfo.InvariantCulture);
                    DateTime date             = Convert.ToDateTime(VarCompetiondate);
                    //string dateTimeEndorse = DateTime.Now.ToString("ddd, dd MMM yyyy");
                    string dateTimeEndorse = date.ToString("ddd, dd MMM yyyy");
                    mail.EndorsementDate = dateTimeEndorse;
                    using (StreamReader reader = new StreamReader(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Template/MailToAllEmployeePerformanceSetting.html")))
                    {
                        mail.Body = reader.ReadToEnd();
                    }
                    mail.Body = mail.Body.Replace("{0}", item.FirstName);
                    string FromToName = string.Empty;
                    mail.Body = mail.Body.Replace("{1}", dateTimeEndorse);
                    string mailFromReceive = Common.sendMailWithoutAttachment(mail);
                }
            }
            return(PartialView("_PartialPearformanceCreate", model));
        }
        public ActionResult SavePerformance(PerformanceSettingViewModel model)
        {
            int userId = SessionProxy.UserId;

            model.CurrentUserId = userId;
            _AdminPearformanceMethod.SaveProjectSet(model);
            List <PerformanceSettingViewModel> modelList = returnList();

            return(PartialView("_partialPerformanceReviewList", modelList));
        }
        public void SaveProjectSet(PerformanceSettingViewModel model)
        {
            Guid obj = Guid.NewGuid();

            if (model.Id > 0)
            {
                PerformanceSetting _Perfromance = _db.PerformanceSettings.Where(x => x.Id == model.Id).FirstOrDefault();
                _Perfromance.ReviewText   = model.ReviewText;
                _Perfromance.AnnualReview = model.AnnualReview;
                if (!string.IsNullOrEmpty(model.CompletionDate))
                {
                    _Perfromance.CompletionDate = DateTime.ParseExact(model.CompletionDate, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture);
                }
                _Perfromance.CompanyCSV           = model.CompanyCSV;
                _Perfromance.LocationCSV          = model.LocationCSV;
                _Perfromance.BusinessCSV          = model.BusinessCSV;
                _Perfromance.DivisionCSV          = model.DivisionCSV;
                _Perfromance.PoolCSV              = model.PoolCSV;
                _Perfromance.FunctionCSV          = model.FunctionCSV;
                _Perfromance.JobRoleCSV           = model.JobRoleCSV;
                _Perfromance.EmploymentTypeCSV    = model.EmploymentTypeCSV;
                _Perfromance.RatingOverAll        = model.RatingOverAll;
                _Perfromance.RatingCore           = model.RatingCore;
                _Perfromance.RatingJobRole        = model.RatingJobRole;
                _Perfromance.OverallScoreJson     = model.OverallScoreJson;
                _Perfromance.CoreSegmentJSON      = model.CoreSegmentJSON;
                _Perfromance.JobRoleSegmentJSON   = model.JobRoleSegmentJSON;
                _Perfromance.CoWorkerSegmentJSON  = model.CoWorkerSegmentJSON;
                _Perfromance.CustomerSegmentJSON  = model.CustomerSegmentJSON;
                _Perfromance.LastModified         = DateTime.Now;
                _Perfromance.UserIDLastModifiedBy = model.CurrentUserId;
                _db.SaveChanges();
            }
            else
            {
                PerformanceSetting _Perfromance = new PerformanceSetting();
                _Perfromance.GuID         = obj.ToString();
                _Perfromance.ReviewText   = model.ReviewText;
                _Perfromance.AnnualReview = model.AnnualReview;
                if (!string.IsNullOrEmpty(model.CompletionDate))
                {
                    _Perfromance.CompletionDate = DateTime.ParseExact(model.CompletionDate, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture);
                }
                _Perfromance.CompanyCSV          = model.CompanyCSV;
                _Perfromance.LocationCSV         = model.LocationCSV;
                _Perfromance.BusinessCSV         = model.BusinessCSV;
                _Perfromance.DivisionCSV         = model.DivisionCSV;
                _Perfromance.PoolCSV             = model.PoolCSV;
                _Perfromance.FunctionCSV         = model.FunctionCSV;
                _Perfromance.JobRoleCSV          = model.JobRoleCSV;
                _Perfromance.EmploymentTypeCSV   = model.EmploymentTypeCSV;
                _Perfromance.RatingOverAll       = model.RatingOverAll;
                _Perfromance.RatingCore          = model.RatingCore;
                _Perfromance.RatingJobRole       = model.RatingJobRole;
                _Perfromance.OverallScoreJson    = model.OverallScoreJson;
                _Perfromance.CoreSegmentJSON     = model.CoreSegmentJSON;
                _Perfromance.JobRoleSegmentJSON  = model.JobRoleSegmentJSON;
                _Perfromance.CoWorkerSegmentJSON = model.CoWorkerSegmentJSON;
                _Perfromance.CustomerSegmentJSON = model.CustomerSegmentJSON;
                _Perfromance.CreatedDate         = DateTime.Now;
                _Perfromance.UserIDCreatedBy     = model.CurrentUserId;
                _db.PerformanceSettings.Add(_Perfromance);
                _db.SaveChanges();
            }
        }
        public ActionResult CopyFrom(PerformanceSettingViewModel model)
        {
            model.ReviewText     = model.ReviewText;
            model.AnnualReview   = (bool)model.AnnualReview;
            model.CompletionDate = String.Format("{0:dd-MM-yyy}", model.CompletionDate);
            var CompanyList = _otherSettingMethod.getAllSystemValueListByKeyName("Company List");

            model.CompanyList.Add(new SelectListItem()
            {
                Text = "All", Value = "All"
            });
            foreach (var item in CompanyList)
            {
                model.CompanyList.Add(new SelectListItem()
                {
                    Text = @item.Value, Value = @item.Id.ToString()
                });
            }
            var LocationList = _otherSettingMethod.getAllSystemValueListByKeyName("Office Locations");

            model.LocationList.Add(new SelectListItem()
            {
                Text = "All", Value = "All"
            });
            foreach (var item in LocationList)
            {
                model.LocationList.Add(new SelectListItem()
                {
                    Text = @item.Value, Value = @item.Id.ToString()
                });
            }
            var BusinessList = _CompanyStructureMethod.getAllBusinessList();

            model.BusinessList.Add(new SelectListItem()
            {
                Text = "All", Value = "All"
            });
            foreach (var item in BusinessList)
            {
                model.BusinessList.Add(new SelectListItem()
                {
                    Text = @item.Name, Value = @item.Id.ToString()
                });
            }
            var DivisionList = _CompanyStructureMethod.getAllDivisionList();

            model.DivisionList.Add(new SelectListItem()
            {
                Text = "All", Value = "All"
            });
            foreach (var item in DivisionList)
            {
                model.DivisionList.Add(new SelectListItem()
                {
                    Text = @item.Name, Value = @item.Id.ToString()
                });
            }
            var PoolList = _CompanyStructureMethod.getAllPoolsList();

            model.PoolList.Add(new SelectListItem()
            {
                Text = "All", Value = "All"
            });
            foreach (var item in PoolList)
            {
                model.PoolList.Add(new SelectListItem()
                {
                    Text = @item.Name, Value = @item.Id.ToString()
                });
            }
            var FunctionListrecord = _CompanyStructureMethod.getAllFunctionsList();

            model.FunctionList.Add(new SelectListItem()
            {
                Text = "All", Value = "All"
            });
            foreach (var item in FunctionListrecord)
            {
                model.FunctionList.Add(new SelectListItem()
                {
                    Text = @item.Name, Value = @item.Id.ToString()
                });
            }
            var jobList = _otherSettingMethod.getAllSystemValueListByKeyName("Job Title List");

            model.JobTitleList.Add(new SelectListItem()
            {
                Text = "All", Value = "All"
            });
            foreach (var item in jobList)
            {
                model.JobTitleList.Add(new SelectListItem()
                {
                    Text = @item.Value, Value = @item.Id.ToString()
                });
            }
            var EmploymentListrecord = _otherSettingMethod.getAllSystemValueListByKeyName("Employment Type List");

            model.EmploymentList.Add(new SelectListItem()
            {
                Text = "All", Value = "All"
            });
            foreach (var item in EmploymentListrecord)
            {
                model.EmploymentList.Add(new SelectListItem()
                {
                    Text = @item.Value, Value = @item.Id.ToString()
                });
            }

            List <PerformanceSetting> data = _AdminPearformanceMethod.getAllList().ToList();

            model.CopyFromList.Add(new SelectListItem()
            {
                Text = "--Select Performance Template--", Value = "0"
            });
            foreach (var item in data)
            {
                model.CopyFromList.Add(new SelectListItem()
                {
                    Text = @item.ReviewText, Value = @item.Id.ToString()
                });
            }
            var performance = _AdminPearformanceMethod.getPerformanceSetById(model.CopyId);

            if (model.CompanyCSV.IndexOf(',') > 0)
            {
                model.selectedCompany = model.CompanyCSV.Split(',').ToList();
            }
            else
            {
                if (!string.IsNullOrEmpty(model.CompanyCSV))
                {
                    string record = model.CompanyCSV;
                    model.selectedCompany.Add(record);
                }
            }

            model.LocationCSV = model.LocationCSV;
            if (model.LocationCSV.IndexOf(',') > 0)
            {
                model.selectedLocation = model.LocationCSV.Split(',').ToList();
            }
            else
            {
                if (!string.IsNullOrEmpty(model.LocationCSV))
                {
                    string record = model.LocationCSV;
                    model.selectedLocation.Add(record);
                }
            }
            model.BusinessCSV = model.BusinessCSV;
            if (model.BusinessCSV.IndexOf(',') > 0)
            {
                model.selectedBusiness = model.BusinessCSV.Split(',').ToList();
            }
            else
            {
                if (!string.IsNullOrEmpty(model.BusinessCSV))
                {
                    string record = model.BusinessCSV;
                    model.selectedBusiness.Add(record);
                }
            }
            model.DivisionCSV = model.DivisionCSV;
            if (model.DivisionCSV.IndexOf(',') > 0)
            {
                model.selectedDivision = model.DivisionCSV.Split(',').ToList();
            }
            else
            {
                if (!string.IsNullOrEmpty(model.DivisionCSV))
                {
                    string record = model.DivisionCSV;
                    model.selectedDivision.Add(record);
                }
            }

            model.PoolCSV = model.PoolCSV;
            if (model.PoolCSV.IndexOf(',') > 0)
            {
                model.selectedPoolList = model.PoolCSV.Split(',').ToList();
            }
            else
            {
                if (!string.IsNullOrEmpty(model.PoolCSV))
                {
                    string record = model.PoolCSV;
                    model.selectedPoolList.Add(record);
                }
            }
            model.FunctionCSV = model.FunctionCSV;
            if (model.FunctionCSV.IndexOf(',') > 0)
            {
                model.selectedFunction = model.FunctionCSV.Split(',').ToList();
            }
            else
            {
                if (!string.IsNullOrEmpty(model.FunctionCSV))
                {
                    string record = model.FunctionCSV;
                    model.selectedFunction.Add(record);
                }
            }
            model.JobRoleCSV = model.JobRoleCSV;
            if (model.JobRoleCSV.IndexOf(',') > 0)
            {
                model.selectedJobTitle = model.JobRoleCSV.Split(',').ToList();
            }
            else
            {
                if (!string.IsNullOrEmpty(model.JobRoleCSV))
                {
                    string record = model.JobRoleCSV;
                    model.selectedJobTitle.Add(record);
                }
            }

            model.EmploymentTypeCSV = model.EmploymentTypeCSV;
            if (model.EmploymentTypeCSV.IndexOf(',') > 0)
            {
                model.selectedEmployment = model.EmploymentTypeCSV.Split(',').ToList();
            }
            else
            {
                if (!string.IsNullOrEmpty(model.EmploymentTypeCSV))
                {
                    string record = model.EmploymentTypeCSV;
                    model.selectedEmployment.Add(record);
                }
            }
            if (performance != null)
            {
                model.CoreSegmentJSON      = performance.CoreSegmentJSON;
                model.CoWorkerSegmentJSON  = performance.CoWorkerSegmentJSON;
                model.JobRoleSegmentJSON   = performance.JobRoleSegmentJSON;
                model.CustomerSegmentJSON  = performance.CustomerSegmentJSON;
                model.RatingOverAll        = performance.RatingOverAll;
                model.RatingCore           = performance.RatingCore;
                model.RatingJobRole        = performance.RatingJobRole;
                model.OverallScoreJsonList = performance.OverallScoreJson.Split('^').ToList();
            }
            if (model.OverallScoreJsonList != null)
            {
                foreach (var item in model.OverallScoreJsonList)
                {
                    model.OverallScoreJsonDetaillistList.Add(new SelectListItem()
                    {
                        Text = item, Value = item
                    });
                }
            }

            return(PartialView("_PartialPearformanceCreate", model));
        }
        public List <PerformanceSettingViewModel> returnList()
        {
            List <PerformanceSetting>          data  = _AdminPearformanceMethod.getAllList().ToList();
            List <PerformanceSettingViewModel> model = new List <PerformanceSettingViewModel>();

            foreach (var item in data)
            {
                PerformanceSettingViewModel Performance = new PerformanceSettingViewModel();
                Performance.Id         = item.Id;
                Performance.ReviewText = item.ReviewText;
                List <string> Company = new List <string>();
                if (item.CompanyCSV == "All" || string.IsNullOrEmpty(item.CompanyCSV))
                {
                    Performance.CompanyCSV = "All";
                }
                else
                {
                    if (!string.IsNullOrEmpty(item.CompanyCSV))
                    {
                        string[] companysplit = item.CompanyCSV.Split(',');
                        foreach (var Companyitem in companysplit)
                        {
                            var list = _AdminPearformanceMethod.CompanyId(Convert.ToInt32(Companyitem));
                            Company.Add(list);
                        }
                        Performance.CompanyCSV = string.Join(",", Company);
                    }
                }
                List <string> Location = new List <string>();
                if (item.LocationCSV == "All" || string.IsNullOrEmpty(item.LocationCSV))
                {
                    Performance.LocationCSV = "All";
                }
                else
                {
                    if (!string.IsNullOrEmpty(item.LocationCSV))
                    {
                        string[] locationsplit = item.LocationCSV.Split(',');
                        foreach (var Locationitem in locationsplit)
                        {
                            var list = _AdminPearformanceMethod.LocationId(Convert.ToInt32(Locationitem));
                            Location.Add(list);
                        }
                        Performance.LocationCSV = string.Join(",", Location);
                    }
                }
                List <string> Business = new List <string>();
                if (item.BusinessCSV == "All" || string.IsNullOrEmpty(item.BusinessCSV))
                {
                    Performance.BusinessCSV = "All";
                }
                else
                {
                    if (!string.IsNullOrEmpty(item.BusinessCSV))
                    {
                        string[] Businesssplit = item.BusinessCSV.Split(',');
                        foreach (var Businessitem in Businesssplit)
                        {
                            var list = _AdminPearformanceMethod.BusinessId(Convert.ToInt32(Businessitem));
                            Business.Add(list);
                        }
                        Performance.BusinessCSV = string.Join(",", Business);
                    }
                }

                List <string> Division = new List <string>();
                if (item.DivisionCSV == "All" || string.IsNullOrEmpty(item.DivisionCSV))
                {
                    Performance.DivisionCSV = "All";
                }
                else
                {
                    if (!string.IsNullOrEmpty(item.DivisionCSV))
                    {
                        string[] Divisionsplit = item.DivisionCSV.Split(',');
                        foreach (var Divisionitem in Divisionsplit)
                        {
                            var list = _AdminPearformanceMethod.DivisionId(Convert.ToInt32(Divisionitem));
                            Division.Add(list);
                        }
                        Performance.DivisionCSV = string.Join(",", Division);
                    }
                }

                List <string> Pool = new List <string>();
                if (item.PoolCSV == "All" || string.IsNullOrEmpty(item.PoolCSV))
                {
                    Performance.PoolCSV = "All";
                }
                else
                {
                    if (!string.IsNullOrEmpty(item.PoolCSV))
                    {
                        string[] Poolsplit = item.PoolCSV.Split(',');
                        foreach (var Poolitem in Poolsplit)
                        {
                            var list = _AdminPearformanceMethod.PoolId(Convert.ToInt32(Poolitem));
                            Pool.Add(list);
                        }
                        Performance.PoolCSV = string.Join(",", Pool);
                    }
                }

                List <string> Function = new List <string>();
                if (item.FunctionCSV == "All" || string.IsNullOrEmpty(item.FunctionCSV))
                {
                    Performance.FunctionCSV = "All";
                }
                else
                {
                    if (!string.IsNullOrEmpty(item.FunctionCSV))
                    {
                        string[] Functionsplit = item.FunctionCSV.Split(',');
                        foreach (var Functionitem in Functionsplit)
                        {
                            var list = _AdminPearformanceMethod.FucantionId(Convert.ToInt32(Functionitem));
                            Function.Add(list);
                        }
                        Performance.FunctionCSV = string.Join(",", Function);
                    }
                }
                List <string> JobTitle = new List <string>();
                if (item.JobRoleCSV == "All" || string.IsNullOrEmpty(item.JobRoleCSV))
                {
                    Performance.JobRoleCSV = "All";
                }
                else
                {
                    if (!string.IsNullOrEmpty(item.JobRoleCSV))
                    {
                        string[] JobTitlesplit = item.JobRoleCSV.Split(',');
                        foreach (var JobTitleitem in JobTitlesplit)
                        {
                            var list = _AdminPearformanceMethod.JobtitleId(Convert.ToInt32(JobTitleitem));
                            JobTitle.Add(list);
                        }
                        Performance.JobRoleCSV = string.Join(",", JobTitle);
                    }
                }
                List <string> EmploymentType = new List <string>();
                if (item.EmploymentTypeCSV == "All" || string.IsNullOrEmpty(item.EmploymentTypeCSV))
                {
                    Performance.EmploymentTypeCSV = "All";
                }
                else
                {
                    if (!string.IsNullOrEmpty(item.EmploymentTypeCSV))
                    {
                        string[] Employmentsplit = item.EmploymentTypeCSV.Split(',');
                        foreach (var Employmentitem in Employmentsplit)
                        {
                            var list = _AdminPearformanceMethod.EmployeementId(Convert.ToInt32(Employmentitem));
                            EmploymentType.Add(list);
                        }
                        Performance.EmploymentTypeCSV = string.Join(",", EmploymentType);
                    }
                }

                model.Add(Performance);
            }
            return(model);
        }