Exemple #1
0
        public HttpResponseMessage Delete(int Id)
        {
            _service.Delete(Id);
            SuccessResponse response = new SuccessResponse();

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Exemple #2
0
        public ResultMsg Delete(int id)
        {
            ResultMsg msg = new ResultMsg();

            try
            {
                var shop = ShopService.GetById(id);
                if (shop != null)
                {
                    var users = MembershipService.QueryUsersOfShops <ShopUser>(null, null, shop.ShopId).ToList();
                    var poses = PosEndPointService.Query(new PosEndPointRequest()
                    {
                        ShopId = shop.ShopId
                    }).ToList();

                    TransactionHelper.BeginTransaction();
                    foreach (ShopUser shopUser in users.ToList())
                    {
                        MembershipService.DeleteUser(shopUser);
                    }
                    foreach (var pos in poses)
                    {
                        PosEndPointService.Delete(pos);
                    }
                    ShopService.Delete(shop);

                    Logger.LogWithSerialNo(LogTypes.ShopDelete, SerialNoHelper.Create(), id, shop.Name);
                    // AddMessage("delete.success", shop.Name);
                    msg.Code     = 1;
                    msg.CodeText = "删除 " + shop.DisplayName + " 成功";
                    TransactionHelper.Commit();

                    CacheService.Refresh(CacheKeys.PosKey);
                }
                else
                {
                    msg.CodeText = "不好意思,没有找到商户";
                }
                return(msg);
            }
            catch (Exception ex)
            {
                msg.CodeText = "不好意思,系统异常";
                Logger.Error("删除商户", ex);
                return(msg);
            }
        }
Exemple #3
0
        public void ShouldDeleteNewShop()
        {
            var newShop = _shopService.Add(EpicShopFixture.NewShop());

            _shopService.Update(newShop.ToViewModel <ShopInputViewModel>(), newShop.Id);
            _shopService.Delete(newShop.Id);

            ShopModel deletedShop = null;

            try
            {
                deletedShop = _shopService.FindById(newShop.Id);
                Assert.True(false, "The should should have been deleted");
            }
            catch (EntityNotFoundExceptions)
            {
                Assert.Null(deletedShop);
            }
        }
Exemple #4
0
 public ActionResult DeleteConfirmed(int id)
 {
     Service.Delete(id);
     return(RedirectToAction("Index"));
 }