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

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

            if (dbItem == null)
            {
                return(NotFound());
            }
            Mapper.Map(mallDayVm, dbItem);
            dbItem.SetModification(UserName);
            _mallDayRepository.Update(dbItem);
            if (!await UnitOfWork.SaveAsync())
            {
                return(StatusCode(500, "保存时出错"));
            }

            return(NoContent());
        }
        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);
            }
        }