public IActionResult DeleteCheckout([FromBody] DeleteCheckoutDto data)
        {
            try
            {
                if (!_checkoutsCore.CheckoutExistsById(data.CheckoutId))
                {
                    ModelState.AddModelError("Invalid ID: ", "No Checkout with that ID was found.");
                    return(BadRequest(ModelState));
                }

                _checkoutsCore.DeleteCheckout(data.CheckoutId);
                return(NoContent());
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                ModelState.AddModelError("Error Deleting Checkout: ", e.Message);
                return(StatusCode(500, ModelState));
            }
        }
Example #2
0
 public IActionResult AddCheckoutToTeam([FromBody] AddCheckoutToTeamDto data)
 {
     try
     {
         if (!checkoutsCore.CheckoutExistsById(data.CheckoutId) || !serverTeamsCore.ServerTeamExists(data.ServerTeamId))
         {
             ModelState.AddModelError("Checkout Not Found", "The checkout ID provided does not match any existing checkouts.");
             return(BadRequest(ModelState));
         }
         serverTeamsCore.AddCheckoutToTeam(data.ServerTeamId, checkoutsCore.GetCheckoutEntityById(data.CheckoutId));
         return(Ok());
     }
     catch (Exception e)
     {
         if (e.InnerException is InvalidOperationException)
         {
             return(BadRequest(e.InnerException));
         }
         ModelState.AddModelError("Add Checkout to Team Failure", e.Message);
         return(StatusCode(500, ModelState));
     }
 }