/// <summary> /// Saves the pay scale benefit edit information. /// </summary> /// <param name="payScaleBenefit">The pay scale benefit.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">payScaleBenefit</exception> public string SavePayScaleBenefitEditInfo(IPayScaleBenefit payScaleBenefit) { if (payScaleBenefit == null) { throw new ArgumentNullException(nameof(payScaleBenefit)); } var result = string.Empty; try { using ( var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { var levelGradeModel = dbContext.PayScaleBenefits.SingleOrDefault(p => p.PayScaleId.Equals(payScaleBenefit.PayScaleId)); levelGradeModel.BenefitId = payScaleBenefit.BenefitId; levelGradeModel.CashValue = payScaleBenefit.CashValue; levelGradeModel.PercentageofBase = payScaleBenefit.PercentageofBase; levelGradeModel.DateModified = DateTime.UtcNow; dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("Save Pay Scale Benefit Edit Info - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }
/// <summary> /// Saves the pay scale benefit. /// </summary> /// <param name="payScaleBenefit">The pay scale benefit.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">payScaleBenefit</exception> public string SavePayScaleBenefit(IPayScaleBenefit payScaleBenefit) { if (payScaleBenefit == null) { throw new ArgumentNullException(nameof(payScaleBenefit)); } var result = string.Empty; var newRecord = new PayScaleBenefit { PayScaleId = payScaleBenefit.PayScaleId, BenefitId = payScaleBenefit.BenefitId, PercentageofBase = payScaleBenefit.PercentageofBase, CashValue = payScaleBenefit.CashValue, DateCreated = DateTime.UtcNow, IsActive = true, }; try { using ( var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { dbContext.PayScaleBenefits.Add(newRecord); dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("Save Pay Scale Benefit - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }