示例#1
0
        public virtual IActionResult Delete(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates))
            {
                return(AccessDeniedView());
            }

            //try to get an affiliate with the specified id
            var affiliate = _affiliateService.GetAffiliateById(id);

            if (affiliate == null)
            {
                return(RedirectToAction("List"));
            }

            _affiliateService.DeleteAffiliate(affiliate);

            //activity log
            _customerActivityService.InsertActivity("DeleteAffiliate",
                                                    string.Format(_localizationService.GetResource("ActivityLog.DeleteAffiliate"), affiliate.Id), affiliate);

            SuccessNotification(_localizationService.GetResource("Admin.Affiliates.Deleted"));

            return(RedirectToAction("List"));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates))
            {
                return(AccessDeniedView());
            }

            var affiliate = _affiliateService.GetAffiliateById(id);

            _affiliateService.DeleteAffiliate(affiliate);
            SuccessNotification(_localizationService.GetResource("Admin.Affiliates.Deleted"));
            return(RedirectToAction("List"));
        }
示例#3
0
        public ActionResult Delete(int id)
        {
            var affiliate = _affiliateService.GetAffiliateById(id);

            if (affiliate == null)
            {
                //No affiliate found with the specified id
                return(RedirectToAction("List"));
            }

            _affiliateService.DeleteAffiliate(affiliate);
            NotifySuccess(T("Admin.Affiliates.Deleted"));
            return(RedirectToAction("List"));
        }
        public async Task <IActionResult> Delete(string id)
        {
            var affiliate = await _affiliateService.GetAffiliateById(id);

            if (affiliate == null)
            {
                //No affiliate found with the specified id
                return(RedirectToAction("List"));
            }

            var customers = new GetCustomerQuery()
            {
                AffiliateId = affiliate.Id,
                PageSize    = 1,
            };
            var query_customer = (await _mediator.Send(customers)).Count();

            if (query_customer > 0)
            {
                ModelState.AddModelError("", "There are exist customers related with affiliate");
            }

            var orders = new GetOrderQuery()
            {
                AffiliateId = affiliate.Id,
                PageSize    = 1,
            };

            var query_order = (await _mediator.Send(orders)).Count();

            if (query_order > 0)
            {
                ModelState.AddModelError("", "There are exist orders related with affiliate");
            }


            if (ModelState.IsValid)
            {
                await _affiliateService.DeleteAffiliate(affiliate);

                Success(_translationService.GetResource("Admin.Affiliates.Deleted"));
                return(RedirectToAction("List"));
            }
            Error(ModelState);
            return(RedirectToAction("Edit", new { id = id }));
        }
示例#5
0
        public IActionResult Delete(string id)
        {
            var affiliate = _affiliateService.GetAffiliateById(id);

            if (affiliate == null)
            {
                //No affiliate found with the specified id
                return(RedirectToAction("List"));
            }
            if (ModelState.IsValid)
            {
                _affiliateService.DeleteAffiliate(affiliate);
                SuccessNotification(_localizationService.GetResource("Admin.Affiliates.Deleted"));
                return(RedirectToAction("List"));
            }
            ErrorNotification(ModelState);
            return(RedirectToAction("Edit", new { id = id }));
        }
示例#6
0
        public ActionResult Delete(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates))
            {
                return(AccessDeniedView());
            }

            var affiliate = _affiliateService.GetAffiliateById(id);

            if (affiliate == null)
            {
                //No affiliate found with the specified id
                return(RedirectToAction("List"));
            }

            _affiliateService.DeleteAffiliate(affiliate);
            NotifySuccess(_localizationService.GetResource("Admin.Affiliates.Deleted"));
            return(RedirectToAction("List"));
        }
示例#7
0
 public async Task DeleteAffiliate_NullParameter_ThrwoException()
 {
     await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await _affiliateService.DeleteAffiliate(null), "affiliate");
 }
示例#8
0
 /// <summary>
 /// Marks affiliate as deleted
 /// </summary>
 /// <param name="affiliate">Affiliate</param>
 public void DeleteAffiliate(Affiliate affiliate)
 {
     _affiliateService.DeleteAffiliate(affiliate);
 }