Пример #1
0
        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));
        }
Пример #2
0
        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());
        }