/// <summary> /// This a) handled optional save to database and b) calling SetupSecondaryData if there are any errors /// It also makes sure that the runStatus is used at the primary return so that warnings are passed on. /// Note: if it did save successfully to the database it alters the message /// </summary> /// <param name="db"></param> /// <param name="bizStatus"></param> /// <returns></returns> protected async Task SaveChangedIfRequiredAndNoErrorsAsync(DbContext db, IBizActionStatus bizStatus) { if (!bizStatus.HasErrors && RequiresSaveChanges) { if (bizStatus.ValidateSaveChanges(Config)) { bizStatus.AddValidationResults(await db.SaveChangesWithValidationAsync()); } else { await db.SaveChangesAsync().ConfigureAwait(false); } Config.UpdateSuccessMessageOnGoodWrite(bizStatus); } }
/// <summary> /// This a) handled optional save to database and b) calling SetupSecondaryData if there are any errors /// It also makes sure that the runStatus is used at the primary return so that warnings are passed on. /// Note: if it did save successfully to the database it alters the message /// </summary> /// <param name="db"></param> /// <param name="bizStatus"></param> /// <returns></returns> protected void SaveChangedIfRequiredAndNoErrors(DbContext db, IBizActionStatus bizStatus) { if (!bizStatus.HasErrors && RequiresSaveChanges) { if (bizStatus.ValidateSaveChanges(Config)) { bizStatus.AddValidationResults(db.SaveChangesWithValidation()); } else { db.SaveChanges(); } Config.UpdateSuccessMessageOnGoodWrite(bizStatus); } }