public async Task <IActionResult> Post([FromBody] MallDayViewModel mallDayVm)
        {
            if (mallDayVm == null)
            {
                return(BadRequest());
            }

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

            var newItem = Mapper.Map <MallDay>(mallDayVm);

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

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

            return(CreatedAtRoute("GetMallDay", new { id = vm.Id }, vm));
        }
        public async Task Initialzie(DateTime date, string userName)
        {
            var dateStr = date.ToString("yyyy-MM-dd");
            var item    = await _collectiveDayRepository.GetSingleAsync(x => x.Date == dateStr, x => x.MallProductSnapshots);

            var products = await _productRepository.All.Where(x => !x.Deleted).ToListAsync();

            var productForMalls = await _productForMallRepository.All.Where(x => !x.Deleted).ToListAsync();

            if (item != null)
            {
                if (item.Initialized)
                {
                    throw new Exception("该商超日已经初始化, 操作失败");
                }
                item.Initialized = true;
                item.SetModification(userName, "初始化");
                InitializeMallProducts(userName, item, productForMalls, products);
                _collectiveDayRepository.Update(item);
            }
            else
            {
                item = new MallDay
                {
                    Date        = dateStr,
                    Initialized = true
                };
                item.SetCreation(userName, "初始化");
                InitializeMallProducts(userName, item, productForMalls, products);
                _collectiveDayRepository.Add(item);
            }
        }