Exemplo n.º 1
0
        public virtual ActionResult Delete(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContributors))
            {
                return(AccessDeniedView());
            }

            var contributor = _contributorService.GetContributorById(id);

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

            //clear associated customer references
            var associatedCustomers = _customerService.GetAllCustomers(contributorId: contributor.Id);

            foreach (var customer in associatedCustomers)
            {
                customer.ContributorId = 0;
                _customerService.UpdateCustomer(customer);
            }

            //delete a contributor
            _contributorService.DeleteContributor(contributor);

            //activity log
            _customerActivityService.InsertActivity("DeleteContributor", _localizationService.GetResource("ActivityLog.DeleteContributor"), contributor.Id);

            SuccessNotification(_localizationService.GetResource("Admin.Contributors.Deleted"));
            return(RedirectToAction("List"));
        }
Exemplo n.º 2
0
 public ActionResult Delete(int id)
 {
     _contributorService.DeleteContributor(id);
     return(Ok());
 }