public async Task <IActionResult> Delete(string[] ids) { Cloudinary cloudinary = CloudAccount.Cloud(); for (int g = 0; g < ids.Count(); g++) { var collectionsFinded = Context.Collections.Include(c => c.User).Where(u => u.UserId.Equals(ids[g])); foreach (Collection collection in collectionsFinded) { cloudinary.DeleteResources(collection.ImageCloudId); } } for (int i = 0; i < ids.Count(); i++) { User usr = await userManager.FindByIdAsync(ids[i]); await userManager.DeleteAsync(usr); } string signeduserId = userManager.GetUserId(HttpContext.User); for (int i = 0; i < ids.Count(); i++) { if (ids[i].Equals(signeduserId)) { return(RedirectToAction("Logout", "Entrance")); } } return(View("UsersManager", userManager.Users)); }
public IActionResult Delete(string[] ids) { Cloudinary cloudinary = CloudAccount.Cloud(); for (int i = 0; i < ids.Count(); i++) { Collection collection = Context.Collections.Find(ids[i]); cloudinary.DeleteResources(collection.ImageCloudId); Context.Collections.Remove(collection); Context.SaveChanges(); } return(RedirectToAction("MyCollections", "Collection")); }