public async Task <IActionResult> SaveNewCheckpointInTask(int taskId, CheckPointDto checkPointDto) { try { return(Ok(await checkPointService.SaveNewCheckpointInTask(taskId, checkPointDto))); } catch (Exception e) { return(NotFound(e.Message)); } }
public async Task <CheckPoint> SaveNewCheckpointInTask(int taskId, CheckPointDto checkpointDto) { if (!await taskRepository.isTaskExist(taskId)) { throw new Exception("task not exist"); } var checkpoint = mapper.Map <CheckPoint>(checkpointDto); await checkpointRepository.SaveCheckPoint(taskId, checkpoint); await checkpointRepository.SaveChanges(); return(checkpoint); }
public async Task <ApiResponse <CheckPoint> > UpdateCheckPoint(CheckPointDto checkPoint) { try { return(await _checkPointServices.UpdateCheckPoint(checkPoint)); } catch (Exception ex) { return(new ApiResponse <CheckPoint>() { Success = false, Errors = new List <string>() { ex.Message } }); } }
public async Task <ApiResponse <CheckPoint> > UpdateCheckPoint(CheckPointDto checkPointDto) { var response = new ApiResponse <CheckPoint>(); try { checkPointDto.UpdatedDate = DateTime.Now; await _checkPointRepository.UpdateAsync(Mapper.Map <CheckPoint>(checkPointDto), checkPointDto.Id); response.Success = true; } catch (Exception ex) { response.Success = false; response.Errors.Add(ex.Message); } return(response); }
public async Task <ApiResponse <CheckPoint> > CreateCheckPoint(CheckPointDto checkPointDto) { var response = new ApiResponse <CheckPoint>(); try { //check videotype Exists var isExistCheckPoint = await _checkPointRepository.CountAsync(i => i.Name == checkPointDto.Name); if (isExistCheckPoint != 0) { response.Success = false; response.Errors.Add("CheckPoint Already Exists"); return(response); } var id = Guid.NewGuid(); //create new videotype var checkPoint = Mapper.Map <CheckPoint>(checkPointDto); checkPoint.Id = id; checkPoint.CreatedDate = DateTime.Now; checkPoint.UpdatedDate = DateTime.Now; checkPoint.IsActive = true; await _checkPointRepository.AddAsyn(checkPoint); response.Data = checkPoint; response.Success = true; } catch (Exception ex) { response.Success = false; response.Errors.Add(ex.Message); } return(response); }