Exemplo n.º 1
0
        public ActionResult AddBakery(AddBakeryViewModel bakery)
        {
            //   var path = Path.Combine(Server.MapPath("~/HinhAnh"), imageselected.FileName);

            ImageModel newimage = db.images.SingleOrDefault(p => p.Id == bakery.nameimage);
            //  imageselected.SaveAs(path);
            Category category  = db.Categorys.SingleOrDefault(p => p.Id == bakery.category_id);
            Bakery   newbakery = new Bakery
            {
                ID       = Guid.NewGuid().ToString(),
                ngaypost = DateTime.Now,
                Name     = bakery.Bakeryname,
                category = category,
                Price    = bakery.Price,
                images   = newimage,
                count    = bakery.quantity
            };

            LogResposibility.Log(User, "Thêm bánh" + newbakery.Name);

            db.Bakerys.Add(newbakery);
            db.SaveChanges();
            return(RedirectToAction("Index"));


            //return View(bakery);
        }
Exemplo n.º 2
0
        public ActionResult AddBakery(AddBakeryViewModel bakery)
        {
            //   var path = Path.Combine(Server.MapPath("~/HinhAnh"), imageselected.FileName);

            ImageModel newimage = this.imagerepository.findimage(bakery.nameimage);
            //  imageselected.SaveAs(path);
            Category category  = this.icategegoryrepository.find(bakery.category_id);
            Bakery   newbakery = new Bakery
            {
                ID       = Guid.NewGuid().ToString(),
                ngaypost = DateTime.Now,
                Name     = bakery.Bakeryname,
                category = category,
                Price    = bakery.Price,
                images   = newimage,
                count    = bakery.quantity
            };


            this.bakeryreposibitory.AddBakery(newbakery);
            // this.ilogrepository.AddLog()
            this.ilogrepository.AddLog(User, "Thêm bánh" + newbakery.Name);
            return(RedirectToAction("Index"));


            //return View(bakery);
        }
Exemplo n.º 3
0
        public JsonResult AddItem(string id)
        {
            var listbakery = Session["listCheckout"] as List <AddBakeryViewModel>;

            if (listbakery == null)
            {
                listbakery = new List <AddBakeryViewModel>();
            }


            var CheckExisit = listbakery.SingleOrDefault(p => p.ID == id);

            if (CheckExisit == null)
            {
                Bakery bakery = db.Bakerys.SingleOrDefault(p => p.ID == id);
                if (bakery == null)
                {
                    return(Json(new
                    {
                        status = 0,
                    }));
                }
                AddBakeryViewModel newBakeryadd = new AddBakeryViewModel()
                {
                    ID         = bakery.ID,
                    Bakeryname = bakery.Name,
                    nameimage  = bakery.images.nameImage,
                    quantity   = 1,
                    Price      = bakery.Price
                };

                listbakery.Add(newBakeryadd);
            }
            else
            {
                CheckExisit.quantity += 1;
            }
            Session["listCheckout"] = listbakery;
            var tongslhang = listbakery.Sum(p => p.quantity);

            return(Json(new
            {
                status = 1,
                data = listbakery,
                tongsl = tongslhang
            }));
        }
Exemplo n.º 4
0
        public ActionResult EditBakery(AddBakeryViewModel bakery)
        {
            if (bakery.ID == null)
            {
                return(HttpNotFound());
            }
            Bakery newbakery = db.Bakerys.Find(bakery.ID);
            //   Category category = db.Categorys.Find(bakery.category_id);
            ImageModel image = db.images.Find(bakery.nameimage);

            if (newbakery == null)
            {
                return(HttpNotFound());
            }

            db.SaveChanges();
            return(View(newbakery));
        }
Exemplo n.º 5
0
        public ActionResult EditBakery(AddBakeryViewModel bakery)
        {
            if (bakery.ID == null)
            {
                return(HttpNotFound());
            }
            Bakery newbakery = bakeryreposibitory.find(bakery.ID);

            //   Category category = db.Categorys.Find(bakery.category_id);
            // ImageModel image = db.images.Find(bakery.nameimage);
            if (newbakery == null)
            {
                return(HttpNotFound());
            }


            return(View(newbakery));
        }