Example #1
0
        public void Delete(string id)
        {
            User customer = Find(id);
            var  orders   = customer.Orders.ToList();

            foreach (var order in orders)
            {
                deleteService.DeleteOrder(order.Id);
            }
            var addresses = customer.Addresses.ToList();

            foreach (var address in addresses)
            {
                db.Addresses.Remove(address);
            }
            var blogComments = customer.BlogPostComments.ToList();

            foreach (var blogComment in blogComments)
            {
                deleteService.DeleteBlogPostComment(blogComment.Id);
            }
            db.SaveChanges();

            userManager.RemoveFromRoles(id, userManager.GetRoles(id).ToArray());
            userManager.Delete(customer);
        }
Example #2
0
        public ActionResult DeleteConfirmed(int[] ids, string fromAction)
        {
            if (ids == null || !ids.Any())
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            foreach (int id in ids)
            {
                deleterService.DeleteBlogPostComment(id);
            }

            return(RedirectToAction(fromAction ?? "Index")
                   .WithWarning(string.Format("The comment has been deleted".TA())));
        }