public async Task <IActionResult> DeleteWorkhoursAsync([FromRoute] Guid workhoursId) { var foundWorkhours = await _workhoursRepository.GetFirstByConditionAsync(j => j.Id == workhoursId); if (foundWorkhours == null) { return(NotFound()); } _workhoursRepository.Delete(foundWorkhours); await _workhoursRepository.SaveChangesAsync(); return(Ok()); }
public async Task <IActionResult> DeleteWorkhoursAsync( [FromRoute, SwaggerParameter("Id of workhours to delete", Required = true)] Guid workhoursId) { var foundWorkhours = await _workhoursRepository.GetFirstByConditionAsync(j => j.Id == workhoursId); if (foundWorkhours == null) { return(NotFound()); } _workhoursRepository.Delete(foundWorkhours); if (!await _workhoursRepository.SaveChangesAsync()) { throw new Exception("Failed to save on deleting"); } return(Ok()); }