Exemplo n.º 1
0
        //private GoodRepository repo = new GoodRepository();

        //public ActionResult Good(int id=16)
        //{
        //    List<Good> goods = db.Goods.Where(g => g.IsFolder == id).ToList();
        //    return PartialView(goods);
        //}

        //public ActionResult Index(int categ=2,int subcateg=16)
        //{
        //    List<Categ> categs = db.Categs.Where(c => c.ParentCategId == null && c.IsVisible == 0).ToList();
        //    return View("Index1",categs);
        //}

        //public ActionResult Edit(int id=2)
        //{
        //    List<Categ> categs = db.Categs.Where(c => c.ParentCategId == id && c.IsVisible==0).ToList();
        //    return  PartialView(categs);
        //}
        public ActionResult Categ(int categ = 2, int subcateg = 16)
        {
            List <Good>  goods;
            List <Categ> subcategs;
            GoodView     goodView = new GoodView();

            if (categ == 2)
            {
                goods     = db.Goods.Where(g => g.IsFolder == subcateg).ToList();
                subcategs = db.Categs.Where(c => c.ParentCategId == categ && c.IsVisible == 0).ToList();
            }
            else
            {
                subcategs = null;
                goods     = db.Goods.Where(g => g.CategId == categ).ToList();
            }
            List <Categ> categs = db.Categs.Where(c => c.ParentCategId == null && c.IsVisible == 0).ToList();

            goodView.Categs     = categs;
            goodView.SubCategs  = subcategs;
            goodView.Goods      = goods;
            goodView.CategID    = categ;
            goodView.SubCategID = subcateg;
            return(View(goodView));
        }
Exemplo n.º 2
0
        //Выбор продукции
        public ActionResult Categ(int ord, int?subcateg, int categ = 2)
        {
            List <Good>  goods;
            List <Categ> subcategs = db.Categs.Where(c => c.ParentCategId == categ && c.IsVisible == 0).ToList();
            GoodView     goodView  = new GoodView();

            goodView.OrderID = ord;
            //int ctg;
            if (subcategs != null && subcategs.Any())
            {
                if (subcateg == null)
                {
                    subcateg = subcategs.ElementAt(0).CategID;
                }
                //else
                //    ctg = (int)subcateg;
                goods = db.Goods.Where(g => g.IsFolder == subcateg).ToList();
                goodView.SubCategID = (int)subcateg;
            }
            else
            {
                subcategs           = null;
                goods               = db.Goods.Where(g => g.CategId == categ).ToList();
                goodView.SubCategID = 0;
            }
            List <Categ> categs = db.Categs.Where(c => c.ParentCategId == null && c.IsVisible == 0).ToList();

            goodView.Categs    = categs;
            goodView.SubCategs = subcategs;
            goodView.Goods     = goods;
            goodView.CategID   = categ;
            //goodView.SubCategID = iif(subcateg==null,0,subcateg);
            return(View(goodView));
        }
Exemplo n.º 3
0
 private async Task changeCodeIfInUse(string code, GoodView c)
 {
     while (await isCodeInUse(code))
     {
         c.Code = GetRandom.Code();
         code   = c.Code;
     }
 }
Exemplo n.º 4
0
 public static async Task OpenView(Good good)
 {
     var page = new GoodView()
     {
         BindingContext = new GoodViewModel(good)
     };
     await App.Current.MainPage.Navigation.PushAsync(page);
 }
Exemplo n.º 5
0
        public async Task <IActionResult> DeleteImg(GoodView c)
        {
            var o = await repository.GetObject(c.ID);

            o.Data.ImgData = null;
            o.Data.ImgName = null;

            await repository.UpdateObject(o);

            return(RedirectToAction("Edit", new { id = c.ID }));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind(properties)] GoodView c, IFormFile file)
        {
            if (!ModelState.IsValid)
            {
                return(View(c));
            }

            var(imgData, imgName) = FileHelper.ParseImageToBytes(file);

            c.ID   = Guid.NewGuid().ToString();
            c.Code = GetRandom.Code();
            await changeCodeIfInUse(c.Code, c);

            await validateId(c.ID, ModelState);

            var o = GoodFactory.Create(c.ID, c.Name, c.Code, c.Description, c.Price, c.Type,
                                       imgData, imgName);

            await repository.AddObject(o);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Edit([Bind(properties)] GoodView c, IFormFile file)
        {
            if (!ModelState.IsValid)
            {
                return(View(c));
            }

            var o = await repository.GetObject(c.ID);

            if (file != null)
            {
                var(imgData, imgName) = FileHelper.ParseImageToBytes(file);
                o.Data.ImgData        = imgData;
                o.Data.ImgName        = imgName;
            }

            o.Data.Name        = c.Name;
            o.Data.Description = c.Description;
            o.Data.Price       = c.Price;

            await repository.UpdateObject(o);

            return(RedirectToAction("Edit"));
        }
Exemplo n.º 8
0
 void Awake()
 {
     instance = this;
     AddButtonEvent(closeBtn, OnClickClose);
     AddButtonEvent(confirmBtn, OnClickConfirm);
 }