12345678910111213141516171819202122232425 |
- using BelovAPI.BaseConnection;
- using BelovAPI.ModelBase;
- using Microsoft.AspNetCore.Mvc;
- namespace BelovAPI.Controllers
- {
- [Route("api/[controller]")]
- [ApiController]
- [ApiExplorerSettings(GroupName = "Действия с пользователем")]
- public class DeleteUser : Controller
- {
- ApplicationContext db = new ApplicationContext();
- [HttpDelete]
- public IActionResult Index(int id)
- {
- User user = db.User.FirstOrDefault(x => x.Id == id);
- db.User.Remove(user);
- db.SaveChanges();
- return Ok($"Вы успешно удалили {user}");
- }
- }
- }
|