Exemple #1
0
 public void TestDelete()
 {
     sut.Delete(new Topping()
     {
         Name = "TestName"
     });
     Assert.AreEqual(1, toppingRepositoryMock.Invocations.Count);
 }
Exemple #2
0
        public ActionResult <SuccessResponse> Delete(int id)
        {
            SuccessResponse response = null;
            ActionResult    result   = null;


            try
            {
                _toppingService.Delete(id);
                response = new SuccessResponse();
                result   = Ok(response);
            }
            catch (Exception ex)
            {
                result = StatusCode(500, new ErrorResponse(ex.Message));
            }

            return(result);
        }
        public IActionResult Delete(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(new ObjectResult(new { Status = 400, Value = "Topping name can't be empty" }));
            }

            try
            {
                toppingService.Delete(new Topping()
                {
                    Name = name
                });
                return(new ObjectResult(new { Status = 200, Value = string.Format("Topping {0} deleted", name) }));
            }
            catch (Exception exception)
            {
                return(new ObjectResult(new { Status = 500, Value = exception.Message }));
            }
        }