public void PayrollSetup_021_UpdateSpiff() { // Arrange SQLHelper.RunSetupScript("UnitTest_PayrollSetup", "A9"); int franchiseID = 39; ReportingService rs = ReportingService.Create <ReportingService>(Guid.NewGuid()); SiteBlue.Business.Reporting.PayrollSetup[] arrPayrollSetup = rs.GetPayrollSetupData(franchiseID); Assert.AreEqual <int>(1, arrPayrollSetup.Length); int payrollSetupID = arrPayrollSetup[0].PayrollSetupID; int payrollSpiffID = arrPayrollSetup[0].PayrollSpiffs.ToArray()[0].PayrollSpiffID; int serviceProID = 172; int jobCodeID = 65834; int payType = 1; decimal rate = 3.5M; DateTime?dateExpires = DateTime.Parse("5/2/2014"); string comments = "Test comments Update Spiff"; bool addOn = true; bool active = true; // Act // Save Spiff to existing PayrollSetup PayrollSetupService payrollSetupService = PayrollSetupService.Create <PayrollSetupService>(Guid.NewGuid()); OperationResult <SiteBlue.Business.PayrollSetup.PayrollSpiff> result = payrollSetupService.PayrollSpiff_Update(payrollSpiffID, serviceProID, jobCodeID, payType, rate, dateExpires, comments, addOn, active); // Assert SiteBlue.Business.PayrollSetup.PayrollSpiff newSpiff = result.ResultData; Assert.AreEqual <int>(payrollSetupID, newSpiff.PayrollSetupID); Assert.AreEqual <int>(serviceProID, newSpiff.ServiceProID); Assert.AreEqual <int>(jobCodeID, newSpiff.JobCodeID); Assert.AreEqual <int>(payType, newSpiff.PayType); Assert.AreEqual <decimal>(rate, newSpiff.Rate); Assert.AreEqual <DateTime?>(dateExpires, newSpiff.DateExpires); Assert.AreEqual <string>(comments, newSpiff.Comments); Assert.AreEqual <bool>(addOn, newSpiff.AddOn); Assert.AreEqual <bool>(active, newSpiff.Active); // Can also check the saved entity SiteBlue.Business.Reporting.PayrollSetup[] arrRptPayrollSetup = rs.GetPayrollSetupData(franchiseID); Assert.AreEqual <int>(1, arrRptPayrollSetup.Length); Assert.AreEqual <int>(1, arrRptPayrollSetup[0].PayrollSpiffs.Count()); SiteBlue.Business.Reporting.PayrollSpiff reportSpiff = arrRptPayrollSetup[0].PayrollSpiffs.ToArray()[0]; Assert.AreEqual <int>(payrollSetupID, reportSpiff.PayrollSetupID); Assert.AreEqual <int>(serviceProID, reportSpiff.ServiceProID); Assert.AreEqual <int>(jobCodeID, reportSpiff.JobCodeID); Assert.AreEqual <int>(payType, reportSpiff.PayTypeID); Assert.AreEqual <decimal>(rate, reportSpiff.Rate); Assert.AreEqual <DateTime?>(dateExpires, reportSpiff.DateExpires); Assert.AreEqual <string>(comments, reportSpiff.Comments); Assert.AreEqual <bool>(addOn, reportSpiff.AddOn); Assert.AreEqual <bool>(active, reportSpiff.Active); }
public ActionResult PayrollSpiffAdd( string strCurrentPayrollSpiffID, string strPayrollSetupID, string strJobCodeID, string strServiceProID, string strPayTypeID, string strRate, string strAddOn, string strDateExpires, string strActive, string strComments) { try { int payrollSpiffID = int.Parse(strCurrentPayrollSpiffID); int payrollSetupID = int.Parse(strPayrollSetupID); int jobCodeID = int.Parse(strJobCodeID); int serviceProID = int.Parse(strServiceProID); int payTypeID = int.Parse(strPayTypeID); decimal rate = decimal.Parse(strRate); bool addOn = strAddOn != null; DateTime dateExpires = DateTime.Parse(strDateExpires); bool active = strActive != null; PayrollSetupService payrollSetupService = PayrollSetupService.Create <PayrollSetupService>(UserInfo.UserKey); OperationResult <SiteBlue.Business.PayrollSetup.PayrollSpiff> result = null; if (payrollSpiffID == -1) { result = payrollSetupService.PayrollSpiff_Add(payrollSetupID, serviceProID, jobCodeID, payTypeID, rate, dateExpires, strComments, addOn, active); } else { result = payrollSetupService.PayrollSpiff_Update(payrollSpiffID, serviceProID, jobCodeID, payTypeID, rate, dateExpires, strComments, addOn, active); } var toReturn = (result.Success == true) ? new { Success = result.Success, Message = "Payroll Spiff saved" } : new { Success = result.Success, Message = "Error: " + result.Message }; return(Json(toReturn)); } catch (Exception ex) { var toReturn = new { Success = false, Message = "Error: " + ex.Message }; return(Json(toReturn)); } }
public void PayrollSetup_021_UpdateSpiff_ThatDoesNotExist() { // Arrange int payrollSpiffID = -1; // not supposed to exist int serviceProID = 172; int jobCodeID = 65834; int payType = 1; decimal rate = 3.5M; DateTime?dateExpires = DateTime.Parse("5/2/2014"); string comments = "Test comments Update Spiff"; bool addOn = true; bool active = true; // Act // Save Spiff to existing PayrollSetup Exception caughtException = null; try { PayrollSetupService payrollSetupService = PayrollSetupService.Create <PayrollSetupService>(Guid.NewGuid()); OperationResult <SiteBlue.Business.PayrollSetup.PayrollSpiff> result = payrollSetupService.PayrollSpiff_Update(payrollSpiffID, serviceProID, jobCodeID, payType, rate, dateExpires, comments, addOn, active); } catch (Exception ex) { caughtException = ex; } // Assert Assert.IsNotNull(caughtException); }