public IHttpActionResult PostMarketEntry(MarketEntryDto marketEntryDto) { if (!ModelState.IsValid) { return(BadRequest()); } var marketEntry = Mapper.Map <MarketEntryDto, MarketEntry>(marketEntryDto); unitOfWork.MarketEntries.Add(marketEntry); unitOfWork.Complete(); return(Created(new Uri(Request.RequestUri + "/" + marketEntry.Id), marketEntryDto)); }
public IHttpActionResult UpdateMarketEntry(int id, MarketEntryDto marketEntryDto) { if (!ModelState.IsValid) { return(BadRequest()); } var marketEntryInDB = unitOfWork.MarketEntries.GetMarketEntry(id); if (marketEntryInDB == null) { return(NotFound()); } Mapper.Map(marketEntryDto, marketEntryInDB); unitOfWork.Complete(); return(Ok()); }