コード例 #1
0
        public ActionResult Create([Bind(Include = "FeedbackID,FeedbackCode,FirstName,Address,Phone,Email,Content,Status,CreateDate")] Feedback feedback)
        {
            if (ModelState.IsValid)
            {
                db.Feedbacks.Add(feedback);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(feedback));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "NewsCategoryID,Name,NCCode,Description,CreateDate,CreateBy,ModifiedDate,ModifiedBy,Status,TopHot")] NewsCategory newsCategory)
        {
            if (ModelState.IsValid)
            {
                db.NewsCategories.Add(newsCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(newsCategory));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "InvoiceID,InvoiceCode,CreateDate,Email,LastName,FirstName,Phone,Address,ghichu,Payment,UserID,UserCode")] Invoice invoice)
        {
            if (ModelState.IsValid)
            {
                db.Invoices.Add(invoice);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(invoice));
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "CategoryID,Name,Description,ParentID,CreateDate,CreateBy,ModifiedDate,ModifiedBy,Status,ShowOnHome")] ProductCategory productCategory)
        {
            if (ModelState.IsValid)
            {
                productCategory.CreateDate = DateTime.Now;
                db.ProductCategories.Add(productCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productCategory));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "ProductID,ProductCode,ProductName,Description,ProductImage,Price,PromotionPrice,Quantity,CategoryID,Detail,Warranty,CreateDate,CreateBy,ModifiedDate,ModifiedBy,Status,TopHot,ViewCounts")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryID = new SelectList(db.ProductCategories, "CategoryID", "Name", product.CategoryID);
            return(View(product));
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "NewsID,Title,MetaTitle,Description,NewsImage,NewsCategoryID,Details,CreateDate,CreateBy,ModifiedDate,ModifiedBy,Status,TopHot,ViewCount")] News news)
        {
            if (ModelState.IsValid)
            {
                db.News.Add(news);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.NewsCategoryID = new SelectList(db.NewsCategories, "NewsCategoryID", "Name", news.NewsCategoryID);
            return(View(news));
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "InvoiceDetailsID,InvoiceID,ProductID,ProductName,UserCode,Price,PromotionPrice,Quantity")] InvoiceDetails invoiceDetails)
        {
            if (ModelState.IsValid)
            {
                db.InvoiceDetails.Add(invoiceDetails);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.InvoiceID = new SelectList(db.Invoices, "InvoiceID", "InvoiceCode", invoiceDetails.InvoiceID);
            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductCode", invoiceDetails.ProductID);
            return(View(invoiceDetails));
        }
コード例 #8
0
        public ActionResult Create([Bind(Include = "CartID,UserID,ProductID,DateOfPurchase,Quantity")] Cart cart)
        {
            if (ModelState.IsValid)
            {
                db.Carts.Add(cart);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductCode", cart.ProductID);
            ViewBag.UserID    = new SelectList(db.Users, "UserID", "UserCode", cart.UserID);
            return(View(cart));
        }
コード例 #9
0
 public ActionResult Signup(User _user)
 {
     if (ModelState.IsValid)
     {
         var check = db.Users.FirstOrDefault(s => s.Username == _user.Username);
         if (check == null)
         {
             db.Configuration.ValidateOnSaveEnabled = false;
             db.Users.Add(_user);
             db.SaveChanges();
             return(RedirectToAction("Login", "Users"));
         }
         else
         {
             ViewBag.error = "Tài khoản đã có người sử dụng";
             return(View());
         }
     }
     return(View());
 }