Modification Zarghatt
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LaDOSE.Business.Interface;
|
||||
using LaDOSE.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LaDOSE.Api.Controllers
|
||||
@@ -35,5 +37,20 @@ namespace LaDOSE.Api.Controllers
|
||||
return _service.GetById(id);
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("{id}/delete")]
|
||||
public IActionResult Delete(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _service.Delete((int) id) ? (IActionResult) NoContent() : NotFound();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LaDOSE.Business.Interface;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -33,5 +34,17 @@ namespace LaDOSE.Api.Controllers
|
||||
return AutoMapper.Mapper.Map<D>(_service.GetById(id));
|
||||
|
||||
}
|
||||
[HttpDelete("{id}")]
|
||||
public IActionResult Delete(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _service.Delete((int)id) ? (IActionResult)NoContent() : NotFound();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,24 +68,24 @@ namespace LaDOSE.Api.Controllers
|
||||
}
|
||||
|
||||
//[AllowAnonymous]
|
||||
//[HttpPost("register")]
|
||||
//public IActionResult Register([FromBody]ApplicationUser userDto)
|
||||
//{
|
||||
// // map dto to entity
|
||||
|
||||
[HttpPost("register")]
|
||||
public IActionResult Register([FromBody]ApplicationUser userDto)
|
||||
{
|
||||
// map dto to entity
|
||||
|
||||
// try
|
||||
// {
|
||||
// // save
|
||||
// _userService.Create(userDto, userDto.Password);
|
||||
// return Ok();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// // return error message if there was an exception
|
||||
// return BadRequest(new { message = ex.Message });
|
||||
// }
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
// save
|
||||
_userService.Create(userDto, userDto.Password);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// return error message if there was an exception
|
||||
return BadRequest(new { message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user