public IActionResult Patch(Guid id, [FromBody] GroceryAction model) { this.logger.LogDebug(this.localizer["LogPatchGroceryActionsTry"].Value); UpdateResult result; try { result = this.groceryActionService.UpdatePartially(id, model); } catch (Exception ex) { this.logger.LogError(ex, this.localizer["LogPatchGroceryActionsError"].Value); return(this.Problem( statusCode: (int)HttpStatusCode.InternalServerError, title: ex.ToString(), detail: ex.StackTrace)); } if (result == null) { this.logger.LogWarning(string.Format(CultureInfo.InvariantCulture, this.localizer["LogPatchGroceryActionsNotFound"].Value)); return(this.NotFound(string.Format(CultureInfo.InvariantCulture, this.localizer["LogPatchGroceryActionsNotFound"].Value))); } this.logger.LogDebug(this.localizer["LogPatchGroceryActionsSuccess"].Value); return(this.Ok(result)); }
public IActionResult Post([FromBody] GroceryAction model) { this.logger.LogDebug(this.localizer["LogPostGroceryActionsTry"].Value); GroceryAction result; try { result = this.groceryActionService.Create(model); } catch (Exception ex) { this.logger.LogError(ex, this.localizer["LogPostGroceryActionsError"].Value); return(this.Problem( statusCode: (int)HttpStatusCode.InternalServerError, title: ex.ToString(), detail: ex.StackTrace)); } if (result == null) { this.logger.LogWarning(string.Format(CultureInfo.InvariantCulture, this.localizer["LogPostGroceryActionsNotFound"].Value)); return(this.NotFound(string.Format(CultureInfo.InvariantCulture, this.localizer["LogPostGroceryActionsNotFound"].Value))); } this.logger.LogDebug(this.localizer["LogPostGroceryActionsSuccess"].Value); return(this.Created(new Uri(this.appSettings.Environment.BackUrl, $"api/groceryactions/{model?.Id}"), result)); }