removed unused code

This commit is contained in:
Mia Rose Winter 2024-03-27 11:10:01 +01:00
parent be8bb535c9
commit e38b32467b
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E

View file

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OutputCaching; using Microsoft.AspNetCore.OutputCaching;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -35,23 +34,4 @@ public class UserController(ImageService imageService, IDbContextFactory<Applica
if (size < 800) return File(await ImageService.GetResized(path, size), ImageService.ImageMimeType); if (size < 800) return File(await ImageService.GetResized(path, size), ImageService.ImageMimeType);
return File(System.IO.File.OpenRead(path), ImageService.ImageMimeType); return File(System.IO.File.OpenRead(path), ImageService.ImageMimeType);
} }
[HttpPost("link/{linkId:int}")]
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
public async Task<IActionResult> DeleteUserLink(int linkId, [FromServices] UserManager<ApplicationUser> userManager) {
if (!string.Equals(Request.Form["_method"], "delete", StringComparison.InvariantCultureIgnoreCase))
return BadRequest();
string returnUrl = Request.Form["ReturnUrl"].FirstOrDefault() ?? string.Empty;
var user = await userManager.GetUserAsync(User);
if (user is null) return Unauthorized();
var link = user.Links.FirstOrDefault(l => l.Id == linkId);
if (link is null) return NotFound();
user.Links.Remove(link);
await userManager.UpdateAsync(user);
return LocalRedirect(string.IsNullOrWhiteSpace(returnUrl) ? "/" : returnUrl);
}
} }