Пример #1
0
        public static SkuModel GetSkuById(Guid Id)
        {
            DBContext _context = new DBContext();
            SkuModel  sku      = SkuMapper.Mapper(_context.Skus.Where(x => x.Id == Id).FirstOrDefault());

            return(sku);
        }
Пример #2
0
        public static List <SkuModel> GetAllSkus()
        {
            DBContext       _context = new DBContext();
            List <SkuModel> skus     = SkuMapper.Mapper(_context.Skus.ToList());

            return(skus);
        }
Пример #3
0
        public IActionResult Upsert(ShowcaseModel sc)
        {
            var       SkuCodes = sc.ShowCaseItemCodes.Split("\r\n");
            DBContext _context = new DBContext();

            if (sc.Id == new Guid())
            {
                sc.Id = Guid.NewGuid();
                _context.Showcases.Add(ShowcaseMapper.Mapper(sc));

                foreach (var item in SkuCodes)
                {
                    ShowcaseItemsModel scs = new ShowcaseItemsModel();
                    scs.ShowCase = sc;
                    scs.Sku      = SkuMapper.Mapper(_context.Skus.Where(x => x.Barcode == item).FirstOrDefault());
                    _context.ShowcaseItems.Add(ShowcaseItemsMapper.Mapper(scs));
                }

                _context.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Пример #4
0
        public IActionResult Upsert(SkuModel sku)
        {
            DBContext     _context = new DBContext();
            LogController logger   = new LogController();

            if (sku.Id == new Guid())
            {
                ProductModel product = ProductController.GetProductById(sku.ProductId);

                product.Skus.Add(sku);
                _context.Products.Update(ProductMapper.Mapper(product));

                logger.LogRegister(sku, "Created", Models.Enums.LogTypeEnum.Skus);
            }
            else
            {
                _context.Skus.Update(SkuMapper.Mapper(sku));
                logger.LogRegister(sku, "Updated", Models.Enums.LogTypeEnum.Skus);
            }

            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }