Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,OrderDate,Amount,UserName")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(order));
        }
Ejemplo n.º 2
0
 public IActionResult Create(Pruduct item)
 {
     if (SContext.Pruducts.Find(item.PId) == null)
     {
         item.PId = item.PId.ToUpper();
         SContext.Pruducts.Add(item);
         SContext.SaveChanges();
         return(CreatedAtRoute("GetShoping", new { id = item.PId }, item));
     }
     return(NotFound());
 }
        public ActionResult Create([Bind(Include = "Id,CategoryName,CategoryRank")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,FeatureName,FeatureDetail,ProductId")] Feature feature)
        {
            if (ModelState.IsValid)
            {
                db.Features.Add(feature);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductId = new SelectList(db.Products, "Id", "ProductName", feature.ProductId);
            return(View(feature));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "Id,ProductId,UnitPrice,Quantity,OrderId")] OrderDetail orderDetail)
        {
            if (ModelState.IsValid)
            {
                db.OrderDetails.Add(orderDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OrderId   = new SelectList(db.Orders, "Id", "UserName", orderDetail.OrderId);
            ViewBag.ProductId = new SelectList(db.Products, "Id", "ProductName", orderDetail.ProductId);
            return(View(orderDetail));
        }
Ejemplo n.º 6
0
        public ActionResult Index_Post(string id)
        {
            Brand brand = new Brand();

            TryUpdateModel(brand);
            if (ModelState.IsValid)
            {
                brand.b_IsActive = 1;
                ShopingContext shpContext = new ShopingContext();
                if (string.IsNullOrEmpty(id))
                {
                    shpContext.brand.Add(brand);
                }
                else
                {
                    brand.Id = Convert.ToInt32(id);
                    shpContext.Entry(brand).State = System.Data.EntityState.Modified;
                }
                int i = shpContext.SaveChanges();
                if (i == 1)
                {
                    return(RedirectToAction("List"));
                }
            }
            return(View());
        }
Ejemplo n.º 7
0
        public ResultModel Create(enterOrder item)
        {
            var result = new ResultModel();

            if (item.qty < 1)
            {
                result.success = false;
                result.meg     = "訂單數量不得為負";
            }
            else if (item.qty < SContext.Pruducts.Find(item.prdId).Qty)
            {
                //如果訂單數量大於產品存貨
                var newOrd = new Order {
                    OId        = DateTime.Now.ToString("yyyyMMddHHmmss"),
                    PruductID  = SContext.Pruducts.Find(item.prdId),
                    orderQty   = item.qty,
                    Members    = SContext.Members.Find(item.memId),
                    CreateTime = DateTime.Now,
                };
                SContext.Orders.Add(newOrd);
                SContext.Pruducts.Find(item.prdId).Qty -= item.qty;
                SContext.SaveChanges();

                result.meg     = "加入訂單成功";
                result.success = true;
                result.data    = newOrd;
            }
            else
            {
                result.meg     = "數量不夠";
                result.success = false;
            }

            return(result);
        }
Ejemplo n.º 8
0
        public ActionResult Index_Post(string id)
        {
            Product product = new Product();

            TryUpdateModel(product);
            if (ModelState.IsValid)
            {
                product.p_IsActive = 1;
                ShopingContext shpContext = new ShopingContext();
                if (string.IsNullOrEmpty(id))
                {
                    shpContext.product.Add(product);
                }
                else
                {
                    product.Id = Convert.ToInt32(id);
                    shpContext.Entry(product).State = System.Data.EntityState.Modified;
                }
                shpContext.SaveChanges();
            }
            getBrand();
            getCategory();
            if (product.Id > 0)
            {
                return(RedirectToAction("Index", "Image", new { Id = product.Id }));
            }
            return(View());
        }
Ejemplo n.º 9
0
        public ActionResult Delete(int id)
        {
            ShopingContext shpContext = new ShopingContext();
            Slider         slider     = shpContext.HomeSlider.Where(x => x.Id == id).FirstOrDefault();

            shpContext.Entry(slider).State = System.Data.EntityState.Deleted;
            shpContext.SaveChanges();
            return(RedirectToAction("List"));
        }
Ejemplo n.º 10
0
        public ActionResult Delete(int id, int Iid)
        {
            ShopingContext shop = new ShopingContext();
            UploadImage    uimp = new UploadImage();

            uimp.Id = Iid;
            shop.Entry(uimp).State = System.Data.EntityState.Deleted;
            shop.SaveChanges();
            return(RedirectToAction("Index", new { id = id }));
        }
        public ActionResult Create([Bind(Include = "Id,ProductName,ProductPrice,ProductImageUrl,ProductRank,CategoryId")] Product product, HttpPostedFileBase imageFile)
        {
            if (ModelState.IsValid)
            {
                string path     = Server.MapPath("~/images") + "/";
                string filename = DateTime.Now.Ticks.ToString() + ".jpeg";


                imageFile.SaveAs(path + filename);

                product.ProductImageUrl = "/images/" + filename;
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", product.CategoryId);
            return(View(product));
        }
Ejemplo n.º 12
0
        public ActionResult Delete(string id)
        {
            category       cgt        = new category();
            ShopingContext shpContext = new ShopingContext();

            cgt.Id = Convert.ToInt32(id);
            shpContext.Entry(cgt).State = System.Data.EntityState.Deleted;
            shpContext.SaveChanges();
            return(RedirectToAction("List"));
        }
Ejemplo n.º 13
0
        public ResultModel CreatePrd(Pruduct item)
        {
            var result = new ResultModel();

            if (SContext.Pruducts.Find(item.PId) == null)
            {
                SContext.Pruducts.Add(item);
                SContext.SaveChanges();
                result.success = true;
                result.meg     = "新增資料成功";
                result.data    = item;
                return(result);
            }
            else
            {
                result.success = false;
                result.meg     = "此ID可能已經存在";
                return(result);
            }
        }
        public ActionResult Index(Activity a)
        {
            if (a.ID > 0)
            {
                a.Status          = "pending";
                a.CreatedAt       = a.StartDate;
                a.UpdatedAt       = a.StartDate;
                db.Entry(a).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            a.Status     = "pending";
            a.CreatedAt  = a.StartDate;
            a.UpdatedAt  = a.StartDate;
            a.AssignedBy = 1;
            a.AssignedTo = 1;

            db.Activities.Add(a);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 15
0
 public ActionResult Index_Post()
 {
     Ecommerce.Areas.admin.Models.Attribute.Attribute attribute = new Ecommerce.Areas.admin.Models.Attribute.Attribute();
     TryUpdateModel(attribute);
     if (ModelState.IsValid)
     {
         attribute.a_isActive = 1;
         ShopingContext shpContext = new ShopingContext();
         shpContext.attribute.Add(attribute);
         shpContext.SaveChanges();
     }
     return(View());
 }
Ejemplo n.º 16
0
        public ResultModel Create(Member item)
        {
            var result = new ResultModel();

            if (SContext.Members.Find(item.UId) == null)
            {
                item.RegisterTime = DateTime.Now;
                SContext.Members.Add(item);
                SContext.SaveChanges();
                result.success = true;
                result.meg     = "註冊成功";
                result.data    = SContext.Members.Find(item.UId);

                return(result);
            }
            else
            {
                result.success = false;
                result.meg     = "註冊失敗,可能已有該帳號";
                return(result);
            }
        }
Ejemplo n.º 17
0
        public ActionResult Index_Post(HttpPostedFileBase Image_URl, string Decription)
        {
            Slider slider = new Slider();

            uploadFile(Image_URl);
            slider.Image_URl  = getfileName;
            slider.Decription = Decription;
            slider.IsActive   = 1;
            if (!string.IsNullOrEmpty(getfileName))
            {
                ShopingContext shpContext = new ShopingContext();
                shpContext.HomeSlider.Add(slider);
                shpContext.SaveChanges();
            }
            return(View(slider));
        }
Ejemplo n.º 18
0
        public ActionResult Delete(string id)
        {
            Brand          brand      = new Brand();
            ShopingContext shpContext = new ShopingContext();

            brand.Id = Convert.ToInt32(id);
            shpContext.Entry(brand).State = System.Data.EntityState.Deleted;
            int i = shpContext.SaveChanges();

            if (i == 1)
            {
                return(RedirectToAction("List"));
            }
            else
            {
                return(RedirectToAction("List"));
            }
        }
Ejemplo n.º 19
0
        public ActionResult Index_Post(string id, string CategoryList, bool addChildCategory)
        {
            category cgt = new category();

            TryUpdateModel(cgt);
            if (ModelState.IsValid)
            {
                ShopingContext shpContext = new ShopingContext();
                if (string.IsNullOrEmpty(id))
                {
                    cgt.c_IsActive = 1;

                    if (addChildCategory)
                    {
                        cgt.c_prent_id = int.Parse(CategoryList);
                        shpContext.category.Add(cgt);
                    }
                    else
                    {
                        shpContext.category.Add(cgt);
                    }
                }
                else
                {
                    if (addChildCategory)
                    {
                        cgt.c_prent_id = int.Parse(CategoryList);
                        shpContext.Entry(cgt).State = System.Data.EntityState.Modified;
                    }
                    else
                    {
                        shpContext.Entry(cgt).State = System.Data.EntityState.Modified;
                    }
                }
                int i = shpContext.SaveChanges();
                if (i == 1)
                {
                    return(RedirectToAction("List"));
                }
            }
            _CategoryList();

            return(View());
        }
        public ActionResult Checkout()
        {
            Cart cart = Cart.GetCartObject(Session);

            // Order and OrderDetails insert/add into database
            Order order = new Order();

            order.Amount       = cart.Amount;
            order.OrderDate    = DateTime.Now;
            order.UserName     = User.Identity.Name;
            order.OrderDetails = cart.OrderDetails;

            _db.Orders.Add(order);
            _db.SaveChanges();

            cart.OrderDetails.Clear();


            ViewBag.Message = "Order has been placed";

            return(View());
        }
Ejemplo n.º 21
0
        public ActionResult Index_Post(string StateID)
        {
            if (StateID == null)
            {
                getCountry();
                return(View());
            }

            ShopingContext shopingContext = new ShopingContext();
            RegisterPro    reg            = new RegisterPro();

            reg.statesId = int.Parse(StateID);
            reg.UserType = "user";
            TryUpdateModel(reg);
            if (ModelState.IsValid)
            {
                //Add or Inser Data In DataBase
                shopingContext.registerPro.Add(reg);
                shopingContext.SaveChanges();
            }
            getCountry();
            return(View());
        }
Ejemplo n.º 22
0
        public ActionResult Index_Post(string statesId)
        {
            if (statesId == null)
            {
                getCountry();
                return(View());
            }
            ShopingContext shopingContext = new ShopingContext();
            RegisterPro    reg            = new RegisterPro();

            reg.statesId = int.Parse(statesId);
            reg.UserType = "user";
            TryUpdateModel(reg);
            if (ModelState.IsValid)
            {
                //Add or Inser Data In DataBase
                shopingContext.Entry(reg).State = System.Data.EntityState.Modified;
                shopingContext.SaveChanges();
            }
            getCountry();
            GetState(reg.countryId);
            return(View());
        }
Ejemplo n.º 23
0
        public ActionResult Index_Post(int id, HttpPostedFileBase searchBoxInput)
        {
            ViewBag.id = id;
            UploadImage image = new UploadImage();

            TryUpdateModel(image);
            if (ModelState.IsValid)
            {
                uploadFile(searchBoxInput);
                image.imageURL = getfileName;
                image.isActive = 1;
                image.p_id     = id;
                if (!string.IsNullOrEmpty(getfileName))
                {
                    ShopingContext shpContext = new ShopingContext();
                    shpContext.uploadImage.Add(image);
                    shpContext.SaveChanges();
                }
            }
            getProduct();
            ProductImages(id);
            return(View());
        }