public ActionResult GetSingleSkipper(ApiVersion version, int id) { SkipperEntity skipperItem = _skipperRepository.GetSingle(id); if (skipperItem == null) { return(NotFound()); } return(Ok(ExpandSingleSkipperItem(skipperItem, version))); }
private dynamic ExpandSingleSkipperItem(SkipperEntity skipperItem, ApiVersion version) { var links = GetLinks(skipperItem.SkipperId, version); SkipperDto item = _mapper.Map <SkipperDto>(skipperItem); var resourceToReturn = item.ToDynamic() as IDictionary <string, object>; resourceToReturn.Add("links", links); return(resourceToReturn); }
public ActionResult <SkipperDto> AddSkipper(ApiVersion version, [FromBody] SkipperCreateDto skipperCreateDto) { if (skipperCreateDto == null) { return(BadRequest()); } SkipperEntity toAdd = _mapper.Map <SkipperEntity>(skipperCreateDto); _skipperRepository.Add(toAdd); if (!_skipperRepository.Save()) { throw new Exception("Creating a skipper failed on save."); } SkipperEntity newSkipperItem = _skipperRepository.GetSingle(toAdd.SkipperId); return(CreatedAtRoute(nameof(GetSingleSkipper), new { version = version.ToString(), id = newSkipperItem.SkipperId }, _mapper.Map <SkipperDto>(newSkipperItem))); }
public SkipperEntity Update(int id, SkipperEntity item) { _dbContext.Skippers.Update(item); return(item); }
public void Delete(int id) { SkipperEntity item = GetSingle(id); _dbContext.Skippers.Remove(item); }
public void Add(SkipperEntity item) { _dbContext.Skippers.Add(item); }