示例#1
0
        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());
        }
示例#2
0
        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());
        }