public bool Update(HostToEventDTO hostToEventDTO) { HostToEvent toUpdate = null; using (UnitOfWork unitOfWork = new UnitOfWork()) { toUpdate = unitOfWork.HteRepo.GetByID(hostToEventDTO.Id); } if (toUpdate != null) { toUpdate.Host_id = hostToEventDTO.Host_id; toUpdate.Event_id = hostToEventDTO.Event_id; } try { using (UnitOfWork unitOfWork = new UnitOfWork()) { unitOfWork.HteRepo.Update(toUpdate); unitOfWork.Save(); } return(true); } catch { return(false); } }
public HostToEventDTO HTEToDto(HostToEvent hte) { if (hte == null) { return(null); } HostToEventDTO hteDto = new HostToEventDTO { Id = hte.Id, Host_id = hte.Host_id, Event_id = hte.Event_id }; return(hteDto); }
public bool Save(HostToEventDTO hostToEventDTO) { HostToEvent hte = new HostToEvent { Host_id = hostToEventDTO.Host_id, Event_id = hostToEventDTO.Event_id }; try { using (UnitOfWork unitOfWork = new UnitOfWork()) { unitOfWork.HteRepo.Insert(hte); unitOfWork.Save(); }; return(true); } catch { return(false); } }
public IHttpActionResult Create(HostToEventDTO hteDto) { ResponseMessage response = new ResponseMessage(); if (hteDto.Validate() == false) { response.Code = 400; response.Body = "Invalid data - Connection has not been saved"; return(Json(response)); } if (_service.Save(hteDto)) { response.Code = 201; response.Body = "Connection has been saved."; } else { response.Code = 200; response.Body = "Connection has not been saved."; } return(Json(response)); }