/// <summary> /// Saves the salary details. /// </summary> /// <param name="userSalaryDetailList">The user salary detail list.</param> /// <returns> /// save salary details to data base /// </returns> public bool SaveSalaryDetails(List <UserSalaryDetailModel> userSalaryDetailList) { foreach (var salarydetail in userSalaryDetailList) { var userSalary = this.syngentaSIPContext.UserSalaryDetails.FirstOrDefault(x => x.Id == salarydetail.Id); if (userSalary != null) { userSalary.StartDate = DateTime.UtcNow.Date; userSalary.LastUpdated = DateTime.UtcNow; userSalary.SalaryInDb = salarydetail.SalaryInDb; //userSalary.VisibilityDate = DateTime.UtcNow.Date; } else { userSalary = new UserSalaryDetailModel { SalaryInDb = salarydetail.SalaryInDb, UserId = salarydetail.UserId, StartDate = DateTime.UtcNow.Date, //VisibilityDate = DateTime.UtcNow.Date, LastUpdated = DateTime.UtcNow }; this.syngentaSIPContext.UserSalaryDetails.Add(userSalary); } this.syngentaSIPContext.Save(); } return(true); }
/// <summary> /// Saves the salary details. /// </summary> /// <param name="salaryDetailViewModel">The salary detail view model.</param> /// <returns> /// returns true if saved else false /// </returns> public bool SaveSalaryDetails(List <SalaryDetailViewModel> salaryDetailViewModel) { List <UserSalaryDetailModel> userSalaryDetailList = new List <UserSalaryDetailModel>(); var applicationSetting = this.applicationSettings.GetApplicationSettingByKeyName(Constants.ApplicationSettingCodes.CryptoKey); if (salaryDetailViewModel != null && salaryDetailViewModel.Count > 0) { foreach (var salary in salaryDetailViewModel) { UserSalaryDetailModel userSalaryDetail = new UserSalaryDetailModel(); userSalaryDetail.Id = salary.Id; userSalaryDetail.UserId = salary.UserId; userSalaryDetail.StartDate = salary.StartDate; userSalaryDetail.SalaryInDb = this.cryptoService.Encrypt(applicationSetting.Value, Convert.ToString(salary.BaseSalary)); userSalaryDetailList.Add(userSalaryDetail); } } return(this.syngentaSIPUnitOfWork.UserRepository.SaveSalaryDetails(userSalaryDetailList)); }