public ActionResult SaveData(BenefitsViewModel model)
        {
            JavaScriptSerializer             js           = new JavaScriptSerializer();
            List <BenefitsDocumentViewModel> listDocument = js.Deserialize <List <BenefitsDocumentViewModel> >(model.DocumentListString);

            _employeeBenefitsMethod.SaveData(model, listDocument, SessionProxy.UserId);

            List <BenefitsViewModel> returnModel = returnBenefitsList(model.EmployeeID);

            return(PartialView("_partialEmployeeBenifitsList", returnModel));
        }
        public ActionResult AddEditBenifits(int Id)
        {
            BenefitsViewModel model = new BenefitsViewModel();

            model.Id = Id;

            model.BenefitList.Add(new SelectListItem()
            {
                Text = "-- Select Benefit --", Value = "0"
            });
            foreach (var item in _otherSettingMethod.getAllSystemValueListByKeyName("Benefit List"))
            {
                model.BenefitList.Add(new SelectListItem()
                {
                    Text = item.Value, Value = item.Id.ToString()
                });
            }
            foreach (var item in _otherSettingMethod.getAllSystemValueListByKeyName("Company Setting Currencies"))
            {
                model.CurrencyList.Add(new SelectListItem()
                {
                    Text = item.Value, Value = item.Id.ToString()
                });
            }
            if (model.Id > 0)
            {
                var benifitDetail = _employeeBenefitsMethod.getBrnifitById(Id);
                model.BenefitID            = benifitDetail.BenefitID;
                model.Currency             = (int)benifitDetail.Currency;
                model.DateAwarded          = String.Format("{0:dd-MM-yyy}", benifitDetail.DateAwarded);
                model.ExpiryDate           = String.Format("{0:dd-MM-yyy}", benifitDetail.ExpiryDate);
                model.FixedAmount          = (decimal)benifitDetail.FixedAmount;
                model.RecoverOnTermination = benifitDetail.RecoverOnTermination;
                model.Comments             = benifitDetail.Comments;

                var caseDoument = _employeeBenefitsMethod.getBenifitDocumentByCaseId(Id);
                foreach (var item in caseDoument)
                {
                    BenefitsDocumentViewModel docModel = new BenefitsDocumentViewModel();
                    docModel.Id           = item.Id;
                    docModel.originalName = item.OriginalName;
                    docModel.newName      = item.NewName;
                    model.BenefitDocumentList.Add(docModel);
                }
            }

            return(PartialView("_partialAddBenifits", model));
        }
        public List <BenefitsViewModel> returnBenefitsList(int EmployeeId)
        {
            List <BenefitsViewModel> model = new List <BenefitsViewModel>();
            var listData = _employeeBenefitsMethod.getBenifitByEmployeeId(EmployeeId);

            foreach (var item in listData)
            {
                BenefitsViewModel m = new BenefitsViewModel();
                m.Id           = item.Id;
                m.BenefitValue = _otherSettingMethod.getSystemListValueById(item.BenefitID).Value;
                m.DateAwarded  = String.Format("{0:dd-MMM-yyy}", item.DateAwarded);
                m.ExpiryDate   = String.Format("{0:dd-MMM-yyy}", item.ExpiryDate);
                m.FixedAmount  = (decimal)item.FixedAmount;
                model.Add(m);
            }

            return(model);
        }
示例#4
0
        public ActionResult DisplayBenefits(string Sorting_Order, string Search_Data, string Filter_Value, int?Page_No, string OrderType)
        {
            /*ViewBag.OrderType = OrderType ?? "desc";
             * ViewBag.CurrentSortOrder = Sorting_Order;
             * Sorting_Order = Sorting_Order ?? "FirstName";*/

            if (Search_Data != null)
            {
                Page_No = 1;
            }
            else
            {
                Search_Data = Filter_Value;
            }

            ViewBag.FilterValue = Search_Data;

            var benefitsList = workerService.GetAllWorkerBenefits(CurrentUser.PersonId);

            int Size_Of_Page = 12;
            int No_Of_Page   = (Page_No ?? 1);

            BenefitsViewModel bVM = new BenefitsViewModel();

            bVM.Benefits   = benefitsList.OrderByDescending(p => p.StartDate).ThenByDescending(n => n.StartDate.Month).ToPagedList(No_Of_Page, Size_Of_Page);
            bVM.PageCount  = (int)Math.Ceiling((double)benefitsList.Count() / Size_Of_Page);
            bVM.PageNumber = Page_No ?? 1;

            var x = workerService.GetAccount(CurrentUser.AccountId).Person;

            bVM.PersonId     = x.Id;
            bVM.FirstName    = x.FirstName;
            bVM.Surname      = x.Surname;
            bVM.Position     = workerService.GetPositionName(x.Employment.PositionCode);
            bVM.Organization = workerService.GetOrganizationName(x.Employment.OrganiziationalUnitCode);
            ViewBag.PersonId = x.Id;

            return(View(bVM));
        }
示例#5
0
        public ActionResult DisplayBenefitsOfWorker(long id, string Sorting_Order, string Search_Data, string Filter_Value, int?Page_No, string OrderType)
        {
            /*ViewBag.OrderType = OrderType ?? "desc";
             * ViewBag.CurrentSortOrder = Sorting_Order;
             * Sorting_Order = Sorting_Order ?? "FirstName";*/

            if (Search_Data != null)
            {
                Page_No = 1;
            }
            else
            {
                Search_Data = Filter_Value;
            }

            ViewBag.FilterValue = Search_Data;

            var benefitsList = hrServices.GetAllWorkerBenefits(id);

            /*if (!String.IsNullOrEmpty(Search_Data))
             * {
             *  benefitsList = benefitsList.Where(stu => stu.FirstName.ToUpper().Contains(Search_Data.ToUpper()) ||
             *                                 stu.Surname.ToUpper().Contains(Search_Data.ToUpper()) ||
             *                                 stu.FirstName.ToUpper().Contains(Search_Data.ToUpper()));///reszta
             * }*/
            /*switch (Sorting_Order)
             * {
             *  case "FirstName":
             *      if (ViewBag.OrderType == "desc")
             *      {
             *          workers = workers.OrderByDescending(stu => stu.FirstName);
             *          ViewBag.OrderType = "asc";
             *      }
             *      else
             *      {
             *          workers = workers.OrderBy(stu => stu.FirstName);
             *          ViewBag.OrderType = "desc";
             *      }
             *      break;
             *  case "Surname":
             *      if (ViewBag.OrderType == "desc")
             *      {
             *          workers = workers.OrderByDescending(stu => stu.Surname);
             *          ViewBag.OrderType = "asc";
             *      }
             *      else
             *      {
             *          workers = workers.OrderBy(stu => stu.Surname);
             *          ViewBag.OrderType = "desc";
             *      }
             *      break;
             *  case "Date":
             *      if (ViewBag.OrderType == "desc")
             *      {
             *          workers = workers.OrderByDescending(stu => stu.DateOfBirth);
             *          ViewBag.OrderType = "asc";
             *      }
             *      else
             *      {
             *          workers = workers.OrderBy(stu => stu.DateOfBirth);
             *          ViewBag.OrderType = "desc";
             *      }
             *      break;
             *  case "Employment":
             *      if (ViewBag.OrderType == "desc")
             *      {
             *          workers = workers.OrderByDescending(stu => stu.Employment.EmploymentType);
             *          ViewBag.OrderType = "asc";
             *      }
             *      else
             *      {
             *          workers = workers.OrderBy(stu => stu.Employment.EmploymentType);
             *          ViewBag.OrderType = "desc";
             *      }
             *      break;
             *  case "Position":
             *      if (ViewBag.OrderType == "desc")
             *      {
             *          workers = workers.OrderByDescending(stu => stu.Employment.PositionCode);
             *          ViewBag.OrderType = "asc";
             *      }
             *      else
             *      {
             *          workers = workers.OrderBy(stu => stu.Employment.PositionCode);
             *          ViewBag.OrderType = "desc";
             *      }
             *      break;
             *  //cd
             *  default:
             *      workers = workers.OrderBy(stu => stu.FirstName);
             *      break;
             * }*/

            int Size_Of_Page = 12;
            int No_Of_Page   = (Page_No ?? 1);

            BenefitsViewModel bVM = new BenefitsViewModel();

            bVM.Benefits   = benefitsList.OrderByDescending(p => p.StartDate).ThenByDescending(n => n.StartDate.Month).ToPagedList(No_Of_Page, Size_Of_Page);
            bVM.PageCount  = (int)Math.Ceiling((double)benefitsList.Count() / Size_Of_Page);
            bVM.PageNumber = Page_No ?? 1;

            var x = hrServices.GetWorker(id);

            bVM.PersonId     = id;
            bVM.FirstName    = x.FirstName;
            bVM.Surname      = x.Surname;
            bVM.Position     = hrServices.GetPositionName(x.Employment.PositionCode);
            bVM.Organization = hrServices.GetOrganizationName(x.Employment.OrganiziationalUnitCode);
            ViewBag.PersonId = id;

            return(View(bVM));
        }
        public void SaveData(BenefitsViewModel model, List <BenefitsDocumentViewModel> documentList, int userId)
        {
            if (model.Id > 0)
            {
                Benefit benfit = _db.Benefits.Where(x => x.Id == model.Id).FirstOrDefault();
                benfit.EmployeeID = model.EmployeeID;
                benfit.BenefitID  = model.BenefitID;
                benfit.Currency   = model.Currency;
                var DateAwardedToString = DateTime.ParseExact(model.DateAwarded, inputFormat, CultureInfo.InvariantCulture);
                benfit.DateAwarded = Convert.ToDateTime(DateAwardedToString.ToString(outputFormat));
                var ExpiryDateToString = DateTime.ParseExact(model.ExpiryDate, inputFormat, CultureInfo.InvariantCulture);
                benfit.ExpiryDate           = Convert.ToDateTime(ExpiryDateToString.ToString(outputFormat));
                benfit.FixedAmount          = model.FixedAmount;
                benfit.RecoverOnTermination = model.RecoverOnTermination;
                benfit.Comments             = model.Comments;
                benfit.Archived             = false;
                benfit.UserIDCreatedBy      = userId;
                benfit.CreatedDate          = DateTime.Now;
                benfit.UserIDLastModifiedBy = userId;
                benfit.LastModified         = DateTime.Now;
                _db.SaveChanges();

                foreach (var item in _db.Benefits_Documents.Where(x => x.BenefitsID == benfit.Id).ToList())
                {
                    _db.Benefits_Documents.Remove(item);
                    _db.SaveChanges();
                }
                foreach (var item in documentList)
                {
                    Benefits_Documents benfitDocument = new Benefits_Documents();
                    benfitDocument.BenefitsID           = benfit.Id;
                    benfitDocument.NewName              = item.newName;
                    benfitDocument.OriginalName         = item.originalName;
                    benfitDocument.Description          = "";
                    benfitDocument.Archived             = false;
                    benfitDocument.UserIDCreatedBy      = userId;
                    benfitDocument.CreatedDate          = DateTime.Now;
                    benfitDocument.UserIDLastModifiedBy = userId;
                    benfitDocument.LastModified         = DateTime.Now;
                    _db.Benefits_Documents.Add(benfitDocument);
                    _db.SaveChanges();
                }
            }
            else
            {
                Benefit benfit = new Benefit();
                benfit.EmployeeID = model.EmployeeID;
                benfit.BenefitID  = model.BenefitID;
                benfit.Currency   = model.Currency;
                var DateAwardedToString = DateTime.ParseExact(model.DateAwarded, inputFormat, CultureInfo.InvariantCulture);
                benfit.DateAwarded = Convert.ToDateTime(DateAwardedToString.ToString(outputFormat));
                var ExpiryDateToString = DateTime.ParseExact(model.ExpiryDate, inputFormat, CultureInfo.InvariantCulture);
                benfit.ExpiryDate           = Convert.ToDateTime(ExpiryDateToString.ToString(outputFormat));
                benfit.FixedAmount          = model.FixedAmount;
                benfit.RecoverOnTermination = model.RecoverOnTermination;
                benfit.Comments             = model.Comments;
                benfit.Archived             = false;
                benfit.UserIDCreatedBy      = userId;
                benfit.CreatedDate          = DateTime.Now;
                benfit.UserIDLastModifiedBy = userId;
                benfit.LastModified         = DateTime.Now;
                _db.Benefits.Add(benfit);
                _db.SaveChanges();

                foreach (var item in documentList)
                {
                    Benefits_Documents benfitDocument = new Benefits_Documents();
                    benfitDocument.BenefitsID           = benfit.Id;
                    benfitDocument.NewName              = item.newName;
                    benfitDocument.OriginalName         = item.originalName;
                    benfitDocument.Description          = "";
                    benfitDocument.Archived             = false;
                    benfitDocument.UserIDCreatedBy      = userId;
                    benfitDocument.CreatedDate          = DateTime.Now;
                    benfitDocument.UserIDLastModifiedBy = userId;
                    benfitDocument.LastModified         = DateTime.Now;
                    _db.Benefits_Documents.Add(benfitDocument);
                    _db.SaveChanges();
                }
            }
        }