public ActionResult Delete(int id)
        {
            var shipper = _shipperService.GetbyId(id);

            _shipperService.Delete(shipper);
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var shipper = await _shipperService.GetId(id);

            await _shipperService.Delete(shipper);

            return(RedirectToAction(nameof(Index)));
        }
Exemple #3
0
 public JsonResult DeleteShipper(int id)
 {
     try
     {
         _shipperService.Delete(id);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return(Json("ok", JsonRequestBehavior.AllowGet));
 }
Exemple #4
0
 public IActionResult Delete(int id)
 {
     if (!ModelState.IsValid)
     {
         return(new BadRequestObjectResult(ModelState));
     }
     else
     {
         _shipperService.Delete(id);
         _shipperService.Save();
         return(new OkResult());
     }
 }
        public async Task <ActionResult> DeleteShipper(int shipperId)
        {
            var existingShipper = await _shipperService.GetById(shipperId);

            if (existingShipper == null)
            {
                return(NotFound());
            }

            await _shipperService.Delete(existingShipper);

            if (await _shipperService.IsSavedToDb())
            {
                return(Ok($"Shipper with id '{shipperId}' has been deleted"));
            }

            return(BadRequest());
        }
        public async Task ShipperWithOrders_Delete_DetachOrdersAndDeleteShipper()
        {
            var shipper = new Shipper();

            var orders = new []
            {
                new Order
                {
                    OrderId     = 1,
                    ShipperId   = 1,
                    ShippedDate = DateTimeOffset.UtcNow,
                    ShipName    = "Name 1"
                },
                new Order
                {
                    OrderId     = 2,
                    ShipperId   = 1,
                    ShippedDate = DateTimeOffset.UtcNow,
                    ShipName    = "Name 2"
                }
            };
            var mockOrders = orders.AsQueryable().BuildMock();

            _orderRepository.Setup(or => or.FindByCondition(It.IsAny <Expression <Func <Order, bool> > >()))
            .Returns(mockOrders.Object);

            await _shipperService.Delete(shipper);

            _shipperRepository.Verify(sh => sh.Delete(shipper));

            var detachedOrders = await mockOrders.Object.ToArrayAsync();

            foreach (var order in detachedOrders)
            {
                Assert.Null(order.ShipperId);
                Assert.Null(order.ShippedDate);
                Assert.Null(order.ShipName);
            }
        }
Exemple #7
0
 public IActionResult Delete(int id)
 {
     ShipperService.Delete(id);
     return(Ok());
 }
Exemple #8
0
        public async Task <bool> Delete(int id)
        {
            await _shipperService.Delete(id);

            return(true);
        }
Exemple #9
0
 public bool Delete(Guid shipperId)
 {
     return(shipperService.Delete(shipperId));
 }