/// <summary> /// Persists model obtained from POST by calling Save in the app scope, returning JSON result /// </summary> public async Task <object> SaveNew(PersistedModel <ChangeResult> model) { model.NonNull(nameof(model)).FormMode = FormMode.Insert; var saved = await App.InjectInto(model) .SaveAsync(); if (saved.IsSuccess) { return(saved.Result); } throw new BusinessException($"Could not save model `{model.GetType().Name}`: {saved.Error.ToMessageWithType()}", saved.Error); }
/// <summary> /// Persists model state obtained from DELETE by calling Save in the app scope, returning JSON result. /// This method can be used to logically delete items via call to PersistedModel.Save() /// </summary> public async Task <object> SaveDeleteAsync(PersistedModel <ChangeResult> model) { model.NonNull(nameof(model)).FormMode = FormMode.Delete; return(await save(model).ConfigureAwait(false)); }