Exemple #1
0
        public ActionResult Create(tablePRODUCT model)
        {
            if (ModelState.IsValid)
            {
                using (var scope = new TransactionScope())
                {
                    //Add Day
                    model.ngaynhap = DateTime.Today;

                    //Add model to database
                    db.tablePRODUCTs.Add(model);
                    db.SaveChanges();

                    //Save file to App_Data
                    var path = Server.MapPath("~/App_Data");
                    path = System.IO.Path.Combine(path, model.idSP.ToString());
                    Request.Files["Image"].SaveAs(path);

                    //Accept all and persistence
                    scope.Complete();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(model));
        }
        public ActionResult Create(tableCUSTOMER model)
        {
            if (ModelState.IsValid)
            {
                db.tableCUSTOMERs.Add(model);
                db.SaveChanges();
                TempData["StatusMessage"] = "Create successfully";
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Exemple #3
0
        public ActionResult Create(tableBILL model)
        {
            if (ModelState.IsValid)
            {
                //Add Day
                model.ngaydathang = DateTime.Today;

                db.tableBILLs.Add(model);
                db.SaveChanges();
                TempData["StatusMessage"] = "Create successfully";
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Exemple #4
0
        public ActionResult Create(Contact model)
        {
            model.thoiGianGui = DateTime.Now.Date;
            if (ModelState.IsValid)
            {
                db.Contacts.Add(model);
                db.SaveChanges();
                return(RedirectToAction("Create"));
            }

            return(View(model));
        }
Exemple #5
0
        public ActionResult Create(tablePRODUCTofYourCart model)
        {
            if (ModelState.IsValid)
            {
                using (var scope = new TransactionScope())
                {
                    // add model to database
                    db.tablePRODUCTofYourCarts.Add(model);
                    db.SaveChanges();
                    TempData["StatusMessage"] = "Create successfully";
                    // save file to App_Data
                    var path = Server.MapPath("~/App_Data");
                    path = System.IO.Path.Combine(path, model.idSP.ToString());
                    Request.Files["Image"].SaveAs(path);
                    // accept all and persistence
                    scope.Complete();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(model));
        }
        public ActionResult TraLoi(Contact model)
        {
            if (model.trangThai == true)
            {
                model.trangThai = true;
            }
            else if (model.traLoi == null)
            {
                model.trangThai = false;
            }
            else
            {
                model.trangThai = true;
            }
            model.thoigianTraLoi = DateTime.Now.Date;

            if (ModelState.IsValid)
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "M4_Admin_TimKiemHienThi"));
            }
            return(View(model));
        }