public async Task DeleteImage(int id, [Remainder] string str = "") { bool insider = Context.Guild.Id == 418900885079588884; var image = ImageDb.GetImage(id); if (image == null) { await Context.Channel.SendMessageAsync($"There is no image with id: **{id}**"); return; } if (!insider && image.GuildId != Context.Guild.Id) { await Context.Channel.SendMessageAsync($"There is no image with id **{id}** in your guild."); return; } await ImageDb.DeleteImage(id); await Context.Channel.SendMessageAsync($"Image **{id}** is gone forever. Why have you done this?"); await ImgurAPI.EditImageAsync(ImgurAPI.ParseId(image.Url), null, image.Id.ToString() + " [DELETED]"); }
public ActionResult Delete(int id) { var db = new ImageDb(Properties.Settings.Default.ConStr); var imageIds = db.GetUserImages(User.Identity.Name).Select(i => i.Id); if (!imageIds.Contains(id)) { return(Redirect("http://www.google.com")); // go away.... } db.DeleteImage(id); return(RedirectToAction("MyAccount")); }