Exemple #1
0
        public async Task <IActionResult> Get(int id)
        {
            var item = await _retailDayRepository.GetSingleAsync(id);

            if (item == null)
            {
                return(NotFound());
            }
            var result = Mapper.Map <RetailDayViewModel>(item);

            return(Ok(result));
        }
Exemple #2
0
        public async Task Initialzie(DateTime date, string userName)
        {
            var dateStr = date.ToString("yyyy-MM-dd");
            var item    = await _retailDayRepository.GetSingleAsync(x => x.Date == dateStr, x => x.RetailProductSnapshots);

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

            var productForRetails = await _productForRetailRepository.All.Where(x => !x.Deleted).ToListAsync();

            if (item != null)
            {
                if (item.Initialized)
                {
                    throw new Exception("该零售日已经初始化, 操作失败");
                }
                item.Initialized = true;
                item.SetModification(userName, "初始化");
                InitializeRetailProducts(userName, item, productForRetails, products);
                _retailDayRepository.Update(item);
            }
            else
            {
                item = new RetailDay
                {
                    Date        = dateStr,
                    Initialized = true
                };
                item.SetCreation(userName, "初始化");
                InitializeRetailProducts(userName, item, productForRetails, products);
                _retailDayRepository.Add(item);
            }
        }
Exemple #3
0
        protected async Task <bool> HasRetailDayBeenInitialized(DateTime?date = null)
        {
            var dateStr = !date.HasValue ? Now.AddDays(1).Date.ToString("yyyy-MM-dd") : date.Value.ToString("yyyy-MM-dd");
            var item    = await RetailDayRepository.GetSingleAsync(x => x.Date == dateStr);

            return(item != null && item.Initialized);
        }