public ActionResult addVoucherProduct()
        {
            System.Diagnostics.Debug.WriteLine("them voucher product");
            int voucherId = Convert.ToInt32(Request.Form["voucherId"]);

            System.Diagnostics.Debug.WriteLine("voucher id" + voucherId);

            voucher v = new voucher {
                id = voucherId
            };

            db.vouchers.Add(v);
            db.vouchers.Attach(v);

            List <Product> products = Session["productVoucher" + voucherId] as List <Product>;
            product        product;

            foreach (Product pro in products)
            {
                product = new product {
                    id = pro.id
                };
                db.products.Add(product);
                db.products.Attach(product);
                v.products.Add(product);
                db.SaveChanges();
            }

            Session.Remove("productVoucher" + voucherId);
            return(RedirectToAction("voucherList", "Voucher"));
        }
Example #2
0
        public ActionResult Add([Bind(Include = "id,activeFlag,createDate,updateDate")] product product2, int catagoryId, int brandId, string name, HttpPostedFileBase imgMain, string code, string description)
        {
            string fileName = System.IO.Path.GetFileName(imgMain.FileName);



            string urlImage = Server.MapPath("~/Content/client/img/product/" + fileName);

            imgMain.SaveAs(urlImage);
            product2.imgMain = fileName;


            product2.brandId     = brandId;
            product2.categoryId  = catagoryId;
            product2.name        = name;
            product2.code        = code;
            product2.description = description;
            product2.activeFlag  = 1;
            product2.createDate  = DateTime.Now;
            product2.updateDate  = DateTime.Now;
            db.products.Add(product2);
            db.SaveChanges();
            return(RedirectToAction("Index"));

            /*            try
             *          {
             *              string fileName = System.IO.Path.GetFileName(imgMain.FileName);
             *              string urlImage = Se00rver.MapPath("~/Image/product/" + fileName);
             *              imgMain.SaveAs(urlImage);
             *              product.brandId = brandId;
             *              product.catagoryId = catagoryId;
             *              product.code = code;
             *              product.description = description;
             *              product.activeFlag = 1;
             *              product.createDate = DateTime.Now;
             *              product.updateDate = DateTime.Now;
             *              db.products.Add(product);
             *              db.SaveChanges();
             *              return RedirectToAction("Index");
             *
             *          }
             *          catch (DbEntityValidationException dbEx)
             *          {
             *              foreach (var validationErrors in dbEx.EntityValidationErrors)
             *              {
             *                  foreach (var validationError in validationErrors.ValidationErrors)
             *                  {
             *                      System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
             *                  }
             *              }
             *          }
             *          return RedirectToAction("Add");
             */
        }
Example #3
0
        public JsonResult addVoucher(VoucherForm voucherForm)
        {
            System.Diagnostics.Debug.WriteLine("name " + voucherForm.Name);
            System.Diagnostics.Debug.WriteLine("product id " + voucherForm.ProductId);
            System.Diagnostics.Debug.WriteLine("voucher id " + voucherForm.VoucherId);
            System.Diagnostics.Debug.WriteLine("price " + voucherForm.Price);
            System.Diagnostics.Debug.WriteLine("start " + voucherForm.StartDate);
            System.Diagnostics.Debug.WriteLine("end " + voucherForm.EndDate);
            string message = "";


            //update
            if (voucherForm.VoucherId != 0)
            {
                voucher  v         = db.vouchers.Find(voucherForm.VoucherId);
                DateTime startDate = DateTime.Parse(voucherForm.StartDate);

                DateTime endDate = DateTime.Parse(voucherForm.EndDate);
                v.startDate = startDate;
                v.endDate   = endDate;
                v.name      = voucherForm.Name;
                v.product   = db.products.Find(voucherForm.ProductId);
                v.price     = voucherForm.Price;

                db.Entry(v).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                voucher v = new voucher();
                v.name    = voucherForm.Name;
                v.price   = voucherForm.Price;
                v.product = db.products.Find(voucherForm.ProductId);
                DateTime startDate = DateTime.Parse(voucherForm.StartDate);

                DateTime endDate = DateTime.Parse(voucherForm.EndDate);
                v.startDate  = startDate;
                v.endDate    = endDate;
                v.createDate = DateTime.Now;
                v.updateDate = DateTime.Now;
                v.activeFlag = 1;
                v.status     = 1;

                this.db.vouchers.Add(v);
                this.db.SaveChanges();

                message = "SUCCESS";
            }



            return(Json(new { Message = message }, JsonRequestBehavior.AllowGet));
        }
 public ActionResult AddCategory([Bind(Include = "id,activeFlag,createDate,updateDate")] category categorys, int parentId, string name, string code, string description)
 {
     categorys.parentId    = parentId;
     categorys.name        = name;
     categorys.code        = code;
     categorys.description = description;
     categorys.activeFlag  = 1;
     categorys.createDate  = DateTime.Now;
     categorys.updateDate  = DateTime.Now;
     db.categories.Add(categorys);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #5
0
        public ActionResult VeryAccount(int id)
        {
            bool Status = false;

            using (dotnetstorephoneEntities1 phone = new dotnetstorephoneEntities1())
            {
                var v = phone.users.Where(a => a.id == id).FirstOrDefault();
                System.Diagnostics.Debug.WriteLine("gggg" + v);
                if (v != null)
                {
                    v.activeFlag = 1;
                    v.createDate = DateTime.Now;
                    v.updateDate = DateTime.Now;
                    phone.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request!";
                }
            }

            ViewBag.Status = Status;
            return(View());
        }
Example #6
0
        public ActionResult Register([Bind(Exclude = "activeFlag")] user user)
        {
            bool   Status  = false;
            String Message = "";

            //model validation
            if (ModelState.IsValid)
            {
                #region //email is already Exits
                var isExist = IsEmailExist(user.email);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email already exist");
                    return(View(user));
                }
                #endregion

                #region Generate activeFlag
                user.activeFlag = 0;

                user.createDate = DateTime.Now;
                user.updateDate = DateTime.Now;
                #endregion

                #region password hashing
                user.password = UtilPass.Hash(user.password);
                #endregion


                #region Save data database
                using (dotnetstorephoneEntities1 phone_Store = new dotnetstorephoneEntities1())
                {
                    phone_Store.users.Add(user);
                    phone_Store.SaveChanges();

                    //Send Email user
                    SendVerificationSendLinkEmail(user.email, user.id);
                    Message = "We have sent you a confirmation link at the email:" + user.email + ".Please confirm!";
                    Status  = true;
                    /*return RedirectToAction("Login", "MyUser");*/
                }
                #endregion
            }
            else
            {
                Message = "Invalid Request";
            }

            ViewBag.Message = Message;
            ViewBag.Status  = Status;

            return(View(user));
        }
        public ActionResult Create(int productId, String fullname, String email, String content)
        {
            if (ModelState.IsValid)
            {
                comment comment = new comment();
                comment.activeFlag = 1;
                comment.createDate = DateTime.Now;
                comment.updateDate = DateTime.Now;
                comment.productId  = productId;
                comment.fullname   = fullname;
                comment.email      = email;
                comment.content    = content;
                using (dotnetstorephoneEntities1 dt = new dotnetstorephoneEntities1())
                {
                    dt.comments.Add(comment);
                    dt.SaveChanges();
                    System.Diagnostics.Debug.WriteLine("gggg" + comment.content + comment.productId);
                }
            }

            return(Redirect("/chitiet/ProductDetail/" + productId));
        }
Example #8
0
        public ActionResult addBrand([Bind(Include = "id,activeFlag,createDate,updateDate")] brand brands, string name, HttpPostedFileBase logo)
        {
            /*  string fileName = System.IO.Path.GetFileName(logo.FileName);
             * string urlImage = Server.MapPath("~/Image/logo/" + fileName);
             * logo.SaveAs(urlImage);
             * brands.logo = "Image/logo/" + fileName;
             * brands.name = name;
             * brands.activeFlag = 1;
             * brands.createDate = DateTime.Now;
             * brands.updateDate = DateTime.Now;
             * db.brands.Add(brands);
             * db.SaveChanges();
             * return RedirectToAction("Index");*/

            /*  string fileName = System.IO.Path.GetFileName(logo.FileName);
             * string urlImage = Server.MapPath("~/Image/logo/" + fileName);
             * logo.SaveAs(urlImage);
             * brands.logo = "Image/logo/" + fileName;
             * brands.name = name;
             * brands.activeFlag = 1;
             * brands.createDate = DateTime.Now;
             * brands.updateDate = DateTime.Now;
             * db.brands.Add(brands);
             * db.SaveChanges();
             * return RedirectToAction("Index");*/

            /*if (ModelState.IsValid)
             * {
             *
             *
             * }
             * else
             * {
             *  if(logo !=null && logo.ContentLength>0)
             *  {
             *      string fileName = System.IO.Path.GetFileName(logo.FileName);
             *      string urlImage = Server.MapPath("~/Image/logo/" + fileName);
             *      logo.SaveAs(urlImage);
             *      brands.logo = "Image/logo/" + fileName;
             *      brands.name = name;
             *      brands.activeFlag = 1;
             *      brands.createDate = DateTime.Now;
             *      brands.updateDate = DateTime.Now;
             *      db.brands.Add(brands);
             *      db.SaveChanges();
             *      return RedirectToAction("Index");*/


            if (logo != null && logo.ContentLength > 0)
            {
                string fileName = System.IO.Path.GetFileName(logo.FileName);



                string urlImage = Server.MapPath("~/Content/client/img/product/" + fileName);
                logo.SaveAs(urlImage);
                brands.logo = fileName;


                brands.name       = name;
                brands.activeFlag = 1;
                brands.createDate = DateTime.Now;
                brands.updateDate = DateTime.Now;
                db.brands.Add(brands);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            if (ModelState.IsValid)
            {
            }
            return(View(brands));
        }
Example #9
0
        public ActionResult Add([Bind(Include = "id,activeFlag,createDate,updateDate")] productdetail productdetail, int productId, int colorId, decimal price, HttpPostedFileBase imgUrl)
        {
            string fileName = System.IO.Path.GetFileName(imgUrl.FileName);
            String date     = DateTime.Now.ToString();

            System.Diagnostics.Debug.WriteLine("date " + date);
            string urlImage = Server.MapPath("~/Content/client/img/product/" + fileName);

            imgUrl.SaveAs(urlImage);
            productdetail.imgUrl = fileName;
            int countSpec = Convert.ToInt32(Request.Form["countSpec"]);

            System.Diagnostics.Debug.WriteLine("product id " + productId);
            System.Diagnostics.Debug.WriteLine("color id " + colorId);
            System.Diagnostics.Debug.WriteLine("price " + price);
            System.Diagnostics.Debug.WriteLine("file name " + fileName);

            System.Diagnostics.Debug.WriteLine("count " + countSpec);

            spec spec = new spec();

            spec.activeFlag = 1;
            spec.createDate = DateTime.Now;
            spec.updateDate = DateTime.Now;
            db.specs.Add(spec);
            db.SaveChanges();

            for (int i = 0; i < countSpec; i++)
            {
                specdetail sd = new specdetail();
                sd.spec = db.specs.Find(spec.id);
                String paramName  = "name_" + i;
                String paramValue = "value_" + i;
                String name       = Convert.ToString(Request.Form[paramName]);
                String value      = Convert.ToString(Request.Form[paramValue]);

                sd.name       = name;
                sd.value      = value;
                sd.activeFlag = 1;
                sd.createDate = DateTime.Now;
                sd.updateDate = DateTime.Now;

                db.specdetails.Add(sd);
                db.SaveChanges();
            }


            productdetail.product    = db.products.Find(productId);
            productdetail.spec       = db.specs.Find(spec.id);
            productdetail.color      = db.colors.Find(colorId);
            productdetail.price      = price;
            productdetail.activeFlag = 1;
            productdetail.createDate = DateTime.Now;
            productdetail.updateDate = DateTime.Now;

            db.productdetails.Add(productdetail);
            db.SaveChanges();


            return(RedirectToAction("productDetailList", "AdminProductDetail", new { productId = productId }));
        }