public ActionResult Create(Contact contact, string Title, string Feedback_Detail)
        {
            if (ModelState.IsValid)
            {
                using (var scope = new TransactionScope())
                {
                    db.Contacts.Add(contact);
                    db.SaveChanges();

                    var detail = new ContactsDetail();
                    detail.Title           = Title;
                    detail.Feedback_Detail = Feedback_Detail;
                    detail.Feedback_ID     = contact.Contact_ID;
                    detail.Date            = DateTime.Now;
                    detail.Contact_ID      = contact.Contact_ID;
                    db.ContactsDetails.Add(detail);
                    db.SaveChanges();

                    scope.Complete();
                    return(RedirectToAction("Index", "Home"));
                }
            }

            return(View(contact));
        }
示例#2
0
        public ActionResult DatHang()
        {
            // Kiem tra don dat hang
            if (Session["GioHang"] == null)
            {
                RedirectToAction("index", "Home");
            }

            // Them don hang
            Order order = new Order();
            List <ShoppingCart> cart = GetShoppingCart();

            order.Delivery_Date = DateTime.Now;
            db.Orders.Add(order);
            db.SaveChanges();
            // Them chi tiet don hang
            foreach (var item in cart)
            {
                Order_Detail order_Detail = new Order_Detail();
                order_Detail.Order_ID = order.Order_ID;
                order_Detail.Watch_ID = item.iMaSP;
                order_Detail.Amount   = (int)item.soLuong;
                db.Order_Detail.Add(order_Detail);
            }
            db.SaveChanges();
            return(RedirectToAction("index", "Home"));
        }
示例#3
0
        public ActionResult Edit(Order order, int Deliver_Status)
        {
            if (ModelState.IsValid)
            {
                order = db.Orders.Find(order.Order_ID);
                order.Order_ChangeDate = DateTime.Now;
                order.Deliver_Status   = Deliver_Status;
                db.Entry(order).State  = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            ViewBag.DS = new SelectList(
                new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Đang xử lý", Value = "1"
                },
                new SelectListItem {
                    Text = "Đã tiếp nhận", Value = "2"
                },
                new SelectListItem {
                    Text = "Đang vận chuyển", Value = "3"
                },
                new SelectListItem {
                    Text = "Đã giao hàng", Value = "4"
                }
            }, "Value", "Text");

            return(View(order));
        }
        public ActionResult Create([Bind(Include = "Watch_ID,Watch_Name,Watch_Description,Watch_Static,WatchType_ID,Original_Price,Selling_Price,InStock")] ProductTable producttable)
        {
            ValidateClock(producttable);


            if (ModelState.IsValid)
            {
                using (var scope = new TransactionScope())
                {
                    // add model to database
                    db.ProductTables.Add(producttable);
                    db.SaveChanges();
                    // save file to app_data
                    var path = Server.MapPath("~/App_Data");
                    path = System.IO.Path.Combine(path, producttable.Watch_ID.ToString());
                    Request.Files["Image"].SaveAs(path + "_0");
                    Request.Files["Image1"].SaveAs(path + "_1");
                    Request.Files["Image2"].SaveAs(path + "_2");
                    // all done successfully
                    scope.Complete();
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.WatchType_ID = new SelectList(db.ProductTypes, "ProductType_ID", "ProductType_Name", producttable.WatchType_ID);
            return(View("Create", producttable));
        }
        public ActionResult Create(Contact contact, string Title, string Feedback_Detail)
        {
            if (ModelState.IsValid)
            {
                using (var scope = new TransactionScope())
                {
                    if (Title.Trim().Equals("") || Feedback_Detail.Trim().Equals(""))
                    {
                        if (Title.Trim().Equals(""))
                        {
                            ModelState.AddModelError("Title", Resource1.nullname);
                        }

                        if (Feedback_Detail.Trim().Equals(""))
                        {
                            ModelState.AddModelError("Feedback_Detail", Resource1.nullname);
                        }
                    }
                    else if (Title.Trim().Equals("") && Feedback_Detail.Trim().Equals(""))
                    {
                        ModelState.AddModelError("Feedback_Detail", Resource1.nullname);
                        ModelState.AddModelError("Title", Resource1.nullname);
                    }

                    else
                    {
                        contact.Status = 1;
                        db.Contacts.Add(contact);
                        db.SaveChanges();

                        var detail = new ContactsDetail();
                        detail.Title           = Title;
                        detail.Feedback_Detail = Feedback_Detail;
                        detail.Feedback_ID     = contact.Contact_ID;
                        detail.Date            = DateTime.Now;
                        detail.Contact_ID      = contact.Contact_ID;
                        db.ContactsDetails.Add(detail);
                        db.SaveChanges();

                        scope.Complete();
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }

            return(View("~/Views/Home/Contact.cshtml"));
        }