Example #1
0
        public ActionResult <Coffee> Delete(int id)
        {
            //Exceptions! Exception does NOT run
            var coff = _CoffeeService.DeleteCoffee(id);

            if (coff == null)
            {
                return(BadRequest("Id Does not exist!"));
                //return StatusCode(404,"Could not find a coffee with that ID!" + id);
            }

            return(Ok($"Coffe with the id: {id} is succesfully deleted"));
        }
Example #2
0
        public async Task <ActionResult> DeleteCoffee(string coffeeDisplayId)
        {
            try
            {
                using (_cofeelogger.BeginScope($"API-DeleteCoffee {DateTime.UtcNow}"))
                {
                    var result = await _coffeeService.DeleteCoffee(coffeeDisplayId).ConfigureAwait(false);

                    _cofeelogger.LogInformation($"API-DeleteCoffee {DateTime.UtcNow}");

                    return(StatusCode((int)result));
                }
            }
            catch (Exception ex)
            {
                _cofeelogger.LogError
                    (ex,
                    $"API-DeleteCoffee-Exception {DateTime.UtcNow}"
                    );

                return(StatusCode((int)HttpStatusCode.BadRequest,
                                  _apiSettings.IsSecuredEnvironment ? "An error occured while processing DeleteCoffee" : ex.ToString()));
            }
        }