Я новичок в asp do tnet и пытаюсь создать веб-API для хранения данных со стороны клиента, и я смог создать HttpPost, но не смог создать конечную точку HttpGet And HttpDelete. Обычно я делал это с помощью картографирования, но здесь я использовал pNet идентификатор ядра, чтобы попробовать новую идею, но не смог заставить его работать, может кто-нибудь помочь мне, пожалуйста, вот мой код:
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using WebApi.Data;
using WebApi.User;
namespace WebApi.Controllers
{
[ApiController]
[Route("api/Application/")]
public class ApplicationUserController : ControllerBase
{
private UserManager<ApplicationUser> userManager;
private SignInManager<ApplicationUser> signInManager;
private readonly DataContext dataContext;
public ApplicationUserController(UserManager<ApplicationUser> userManager, DataContext dataContext, SignInManager<ApplicationUser> signInManager)
{
this.userManager = userManager;
this.signInManager = signInManager;
this.dataContext = dataContext;
}
[HttpPost]
[Route("register")]
public async Task<Object>CreateUser(ApplicationUserDTO user)
{
user.Role = "Member";
var applicationUser = new ApplicationUser()
{
UserName = user.UserName,
FullName = user.FullName,
PhoneNumber = user.PhoneNumber,
Email = user.Email
};
try
{
var result = await userManager.CreateAsync(applicationUser, user.Password);
await userManager.AddToRoleAsync(applicationUser, user.Role);
return Ok(result);
}
catch(Exception ex)
{
throw ex;
}
}
//To Do
// create Httpget and HttpDelete
}
}
ApplicationUser.cs
using Microsoft.AspNetCore.Identity;
namespace WebApi.User
{
public class ApplicationUser:IdentityUser
{
public string FullName { get; set; }
}
}
ApplicationUserDTO.cs
using System;
namespace WebApi.User
{
public class ApplicationUserDTO
{
public Guid Id { get; set; }
public string UserName { get; set; }
public string FullName { get; set; }
public string PhoneNumber { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string Role { get; set; }
}
}
спасибо !!