public async Task <IActionResult> LockProjectAsync(int projectId, [FromServices] ILockProjectCommand command) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userId = 1; // From identity var response = await command.ExecuteAsync(projectId, userId); if (!response) { return(NotFound()); } return(Ok()); }
public async Task <IActionResult> LockProjectAsync(int projectId, [FromServices] ILockProjectCommand command) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } string user = User.Identity.Name; try { var response = await command.ExecuteAsync(projectId, user); return(!response ? (IActionResult)NotFound() : Ok()); } catch (ProjectLockedException) { return(BadRequest("В данный момент проект уже заблокирован!")); } }