public async Task <IActionResult> Put(int id, [FromBody] RetailPromotionGiftOrderViewModel retailPromotionGiftOrderVm)
        {
            if (retailPromotionGiftOrderVm == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var dbItem = await _retailPromotionGiftOrderRepository.GetSingleAsync(id);

            if (dbItem == null)
            {
                return(NotFound());
            }
            Mapper.Map(retailPromotionGiftOrderVm, dbItem);
            dbItem.SetModification(UserName);
            _retailPromotionGiftOrderRepository.Update(dbItem);
            if (!await UnitOfWork.SaveAsync())
            {
                return(StatusCode(500, "保存时出错"));
            }
            var vm = Mapper.Map <RetailPromotionGiftOrderViewModel>(dbItem);

            return(Ok(vm));
        }
        public async Task <IActionResult> Post([FromBody] RetailPromotionGiftOrderViewModel retailPromotionGiftOrderVm)
        {
            if (retailPromotionGiftOrderVm == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newItem = Mapper.Map <RetailPromotionGiftOrder>(retailPromotionGiftOrderVm);

            newItem.SetCreation(UserName);
            _retailPromotionGiftOrderRepository.Add(newItem);
            if (!await UnitOfWork.SaveAsync())
            {
                return(StatusCode(500, "保存时出错"));
            }

            var vm = Mapper.Map <RetailPromotionGiftOrderViewModel>(newItem);

            return(CreatedAtRoute("GetRetailPromotionGiftOrder", new { id = vm.Id }, vm));
        }