SES-84 Created User registration method #27
@ -1,5 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SessionCompanion.Services.Interfaces;
|
using SessionCompanion.Services.Interfaces;
|
||||||
|
using SessionCompanion.ViewModels.UserViewModels;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SessionCompanion.Controllers
|
namespace SessionCompanion.Controllers
|
||||||
@ -22,5 +23,17 @@ namespace SessionCompanion.Controllers
|
|||||||
if (User.Password == password) { return Json(User.Id); }
|
if (User.Password == password) { return Json(User.Id); }
|
||||||
return BadRequest();
|
return BadRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("register")]
|
||||||
|
|
||||||
|
public async Task<IActionResult> Register(UserViewModel model)
|
||||||
|
{
|
||||||
|
if(!ModelState.IsValid)
|
||||||
|
return BadRequest();
|
||||||
|
await _service.Create(model);
|
||||||
|
await _service.SaveAsync();
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user