Beispiel #1
0
        public IHttpActionResult PutProductCategory(long id, ProductCategory productCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != productCategory.ID)
            {
                return(BadRequest());
            }

            db.Entry(productCategory).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductCategoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult PutAbout(long id, About about)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != about.ID)
            {
                return(BadRequest());
            }

            db.Entry(about).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AboutExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public IHttpActionResult PutBill(int id, Bill bill)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bill.ID)
            {
                return(BadRequest());
            }

            db.Entry(bill).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BillExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        //[ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "ID,Name,Address,Email,Phone,Note,Product,TotalPrice")] Bill bill)
        {
            if (ModelState.IsValid)
            {
                db.Bills.Add(bill);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bill));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "ID,Name,MetaTitle,ParentID,DisplayOrder,SeoTitle,CreateDate,CreateBy,ModifiedDate,ModifiedBy,MetaKeywords,MetaDesciptions,Status,ShowOnHome")] ProductCategory productCategory)
        {
            if (ModelState.IsValid)
            {
                db.ProductCategories.Add(productCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productCategory));
        }
        public ActionResult Create([Bind(Include = "ID,Name,Code,MetaTile,Description,Image,MoreImages,Price,PromotionPrice,IncludeVAT,Quantity,CategoryID,Detail,CreateDate,CreateBy,ModifiedDate,ModifiedBy,MetaKeywords,MetaDesciptions,Status,TopHot")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
Beispiel #7
0
        public ActionResult Edit(User user)
        {
            if (ModelState.IsValid)
            {
                //{
                //    var DAO = new UserDAO();

                //    var encryptedMD5Password = Encryptor.MD5Hash(user.Password);
                //    user.Password = encryptedMD5Password;

                //    var result = DAO.Update(user);
                //    if (result)
                //    {
                //        ModelState.AddModelError("", "Cập nhật bản ghi thành công");
                //        return RedirectToAction("Index", "User");
                //    }
                //    else
                //    {
                //        ModelState.AddModelError("", "Thêm mới bản ghi thất bại");
                //    }
                var encryptedMD5Password = Encryptor.MD5Hash(user.Password);
                user.Password = encryptedMD5Password;

                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();

                TempData["notify"] = "Edit data success";
                return(RedirectToAction("Index"));
            }
            return(View("Index"));
        }
Beispiel #8
0
 public long Insert(User entity)
 {
     db.Users.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }