public DTO.PutInsertToDoDataResponse InsertToDo(DTO.PutInsertToDoDataRequest request) { PutInsertToDoDataResponse respone = new PutInsertToDoDataResponse(); ISchedulingRepository repo = Factory.GetRepository(request, RepositoryType.ToDo); string toDoId = (string)repo.Insert(request); if (!string.IsNullOrEmpty(toDoId)) { ToDoData data = (ToDoData)repo.FindByID(toDoId); respone.ToDoData = data; } return(respone); }
public PutInsertToDoDataResponse InsertToDo(PutInsertToDoDataRequest request) { PutInsertToDoDataResponse respone = new PutInsertToDoDataResponse(); try { ISchedulingRepository repo = Factory.GetRepository(request, RepositoryType.ToDo); string toDoId = (string)repo.Insert(request); if (!string.IsNullOrEmpty(toDoId)) { ToDoData data = (ToDoData)repo.FindByID(toDoId); respone.ToDoData = data; } } catch (Exception ex) { throw ex; } return(respone); }
public Scheduling Insert(Scheduling entity) { try { entity.SchedulingKey = Guid.NewGuid(); var address = _addressRepository.Get(entity.Address.AddressKey); if (address == null) { throw new NotFoundException("Address not found"); } var hasScheduling = _schedulingRepository.Exists(entity); if (!hasScheduling) { entity.Address = address; return(_schedulingRepository.Insert(entity)); } throw new ForbbidenException("Scheduling already exists"); } catch (ForbbidenException ex) { throw new ForbbidenException($"Not was possible insert the Scheduling: {ex.Message}"); } catch (NotFoundException ex) { throw new NotFoundException($"Not was possible insert the Scheduling: {ex.Message}"); } catch (Exception ex) { throw new InternalServerErrorException($"Not was possible insert the Scheduling: {ex.Message}"); } }