Exemple #1
0
        public async Task TestMethod_測試DeleteShipper()
        {
            var ShipperID = await GetMaxId();

            var result = await shipperService.DeleteShipper(ShipperID);

            Assert.AreEqual(result, 1);
        }
Exemple #2
0
        public async Task <ActionResult <ShipperAPIModel> > DeleteShipper(int id)
        {
            var shipperToBeDeleted = await _shipperService.GetShipperById(id);

            var shipperAPIModel = _mapper.Map <Shippers, ShipperAPIModel>(shipperToBeDeleted);

            await _shipperService.DeleteShipper(shipperToBeDeleted);

            return(Ok(shipperAPIModel));
        }
        public async Task <IActionResult> Delete(int id)
        {
            var result = await _shippderService.DeleteShipper(id);

            if (result > 0)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Exemple #4
0
        public ActionResult DeleteAccount(Guid Id)
        {
            try
            {
                var result = _accountService.GetAccount(Id);
                if (result != null)
                {
                    if (_shipperService.GetShippers(s => s.AccountId == Id).Count() > 0)
                    {
                        var shipper = _shipperService.GetShippers(s => s.AccountId == Id).ToList();
                        _shipperService.DeleteShipper(shipper.FirstOrDefault());
                        _shipperService.Save();
                    }

                    if (_customerService.GetCustomers(c => c.AccountId == Id).Count() > 0)
                    {
                        var customer = _customerService.GetCustomers(s => s.AccountId == Id).ToList();
                        _customerService.DeleteCustomer(customer.FirstOrDefault());
                        _customerService.Save();
                    }

                    if (_storeService.GetStores(s => s.AccountId == Id).Count() > 0)
                    {
                        var store = _storeService.GetStores(s => s.AccountId == Id).ToList();

                        _storeService.DeleteStore(store.FirstOrDefault());
                        var listService = _serviceService.GetServices(s => s.StoreId == store[0].Id).ToList();
                        foreach (var item in listService)
                        {
                            _serviceService.DeleteService(item);
                        }
                        _serviceService.Save();
                        _storeService.Save();
                    }
                    _accountService.DeleteAccount(result);
                    _accountService.Save();
                    return(Ok(201));
                }
                return(NotFound());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
 public void Delete(string id)
 {
     _shipperService.DeleteShipper(id);
 }