Exemple #1
0
        public JsonResult CreateSlide(string urlimg, string slogan1, string slogan2, string title, string link, string target, int?sort)
        {
            string result = "FAIL";

            try
            {
                Slide s = new Slide();
                s.ImageURL   = urlimg;
                s.Slogun1    = slogan1;
                s.Slogun2    = slogan2;
                s.SlideTitle = title;
                s.LinkBanner = link;
                s.LinkTarget = target;
                s.Sort       = sort;
                s.CategoryID = 0;
                s.CreateBy   = db.Users.FirstOrDefault(q => q.UserName == User.Identity.Name).UserID;
                s.Created    = DateTime.Now;
                s.IsActive   = true;
                db.Slides.Add(s);

                db.SaveChanges();
                result = "DONE";
            }
            catch
            {
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "CustomerContactID,CustomerName,CustomerEmail,CustomerPhone,CustomerAddress,CustomerContent,ContactTypeId,Created")] CustomerContact customerContact)
        {
            if (ModelState.IsValid)
            {
                db.CustomerContacts.Add(customerContact);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ContactTypeId = new SelectList(db.CustomerContactTypes, "Id", "TypeName", customerContact.ContactTypeId);
            return(View(customerContact));
        }
        public ActionResult Create([Bind(Include = "Id,LibraryName,LibraryDesc,Created")] PhotoLibraryCategory photoLibraryCategory)
        {
            if (ModelState.IsValid)
            {
                photoLibraryCategory.Created = DateTime.Now;
                db.PhotoLibraryCategories.Add(photoLibraryCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(photoLibraryCategory));
        }
Exemple #4
0
        public ActionResult Create([Bind(Include = "Id,CarCode,CustID,AddresDelivery,CustPhone,TimeDelivery,ShipDelivery,Qty,Total,VouchersCode,VourcerMoney,TotalConLai,Notes,StatusOrder,StyleShip,Created,Updated")] Cart cart)
        {
            if (ModelState.IsValid)
            {
                db.Carts.Add(cart);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustID = new SelectList(db.CustomerOrders, "Id", "CustName", cart.CustID);
            return(View(cart));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "BlogID,BlogName,ImageURL,Descript,Content,TypeBlog,CountView,IsActive,CategoryID,Created,CreatedBy,SEOTitle,SEOUrlRewrite,SEOKeywords,SEOMetadescription")] Blog blog,
                                   HttpPostedFileBase HinhAnh)
        {
            if (ModelState.IsValid)
            {
                var allowedExtensions = new[] {
                    ".Jpg", ".png", ".jpg", "jpeg"
                };
                if (HinhAnh == null)
                {
                    blog.ImageURL = "NoImage.png";
                }
                else
                {
                    var fileName = Path.GetFileName(HinhAnh.FileName);

                    var ext = Path.GetExtension(HinhAnh.FileName);
                    if (allowedExtensions.Contains(ext))                             //check what type of extension
                    {
                        string name   = Path.GetFileNameWithoutExtension(fileName);  //getting file name without extension
                        string myfile = name + "_" + DateTime.Now.Millisecond + ext; //appending the name with id
                                                                                     // store the file inside ~/project folder(Img)

                        var path = Path.Combine(Server.MapPath(WebConstants.imgNewsURL), myfile);
                        //var dir = Directory.CreateDirectory(path);
                        //HinhAnh.SaveAs(Path.Combine(path, myfile));

                        blog.ImageURL = myfile;
                        HinhAnh.SaveAs(path);
                    }
                    else
                    {
                        ViewBag.message = "Please choose only Image file";
                    }
                }

                blog.SEOUrlRewrite = Helpers.ConvertToUpperLower(blog.BlogName);
                blog.TypeBlog      = WebConstants.BlogNews;
                blog.CreatedBy     = db.Users.FirstOrDefault(q => q.UserName == User.Identity.Name).UserID;
                blog.Created       = DateTime.Now;
                blog.LastModify    = DateTime.Now;
                blog.CountView     = 1;
                db.Blogs.Add(blog);
                db.SaveChanges();
                Success(string.Format("Thêm mới bài viết thành công.", ""), true);
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", blog.CategoryID);
            ViewBag.CreatedBy  = new SelectList(db.Users, "UserID", "UserName", blog.CreatedBy);
            return(View(blog));
        }
Exemple #6
0
        public ActionResult Create([Bind(Include = "Id,Question,Answer,IsActive,ThuTu,Created,LastModify")] Q_A q_A)
        {
            if (ModelState.IsValid)
            {
                q_A.Created    = DateTime.Now;
                q_A.LastModify = DateTime.Now;
                db.Q_A.Add(q_A);
                db.SaveChanges();
                return(RedirectToAction("Index", "Q_A"));
            }

            return(View(q_A));
        }
        public ActionResult Create([Bind(Include = "ProductID,ProductCode,ProductName,Capacity,Price,PricePhanTram,PriceSale,Capacity1,Price1,PricePhanTram1,PriceSale1," +
                                                   "CategoryIDParent,CategoryID,Images,ImagesThumb,ShortDescription,Content,InStock,IsSale,IsNew,Rating,IsActive,CountView,Created,CreatedBy,SEOTitle,SEOUrlRewrite,SEOKeywords,SEOMetadescription")] Product product,
                                   HttpPostedFileBase HinhAnh)
        {
            if (ModelState.IsValid)
            {
                var allowedExtensions = new[] {
                    ".Jpg", ".png", ".jpg", "jpeg"
                };
                if (HinhAnh == null)
                {
                    product.Images = "NoImage.png";
                }
                else
                {
                    var fileName = Path.GetFileName(HinhAnh.FileName);

                    var ext = Path.GetExtension(HinhAnh.FileName);
                    if (allowedExtensions.Contains(ext))                             //check what type of extension
                    {
                        string name   = Path.GetFileNameWithoutExtension(fileName);  //getting file name without extension
                        string myfile = name + "_" + DateTime.Now.Millisecond + ext; //appending the name with id
                                                                                     // store the file inside ~/project folder(Img)

                        var path = Path.Combine(Server.MapPath(WebConstants.ImgProduct), myfile);
                        //var dir = Directory.CreateDirectory(path);
                        //HinhAnh.SaveAs(Path.Combine(path, myfile));

                        product.Images = myfile;
                        HinhAnh.SaveAs(path);

                        product.ImagesThumb = CreateThumb(myfile);
                    }
                    else
                    {
                        ViewBag.message = "Please choose only Image file";
                    }
                }
                product.CategoryIDParent = product.CategoryID;
                product.IsProduct        = true;


                product.SEOUrlRewrite = Helpers.ConvertToUpperLower(product.ProductName);
                product.Created       = DateTime.Now;
                product.CreatedBy     = db.Users.FirstOrDefault(q => q.UserName == User.Identity.Name).UserID;
                //product.CreatedBy = 1;
                db.Products.Add(product);
                db.SaveChanges();
                Success(string.Format("Thêm mới sản phẩm<b>{0}</b> thành công.", product.ProductName), true);
                return(RedirectToAction("Details", "Products", new { id = product.ProductID }));
            }

            ViewBag.CategoryIDParent = new SelectList(db.Categories.Where(c => c.Parent == 0), "CategoryID", "CategoryName", product.CategoryIDParent);
            ViewBag.CategoryID       = new SelectList(db.Categories, "CategoryID", "CategoryName", product.CategoryID);
            ViewBag.CreatedBy        = new SelectList(db.Users, "UserID", "UserName", product.CreatedBy);
            Success(string.Format("Thêm mới sản phẩm<b>{0}</b> thành công.", product.ProductName), true);
            //return RedirectToAction("Index");
            return(View(product));
        }
        public ActionResult Create([Bind(Include = "CategoryID,CategoryName,Parent,DisplayMenu,IsActive,Sort,TypeCate,SEOTitle,SEOUrlRewrite,SEOKeywords,SEOMetadescription")] Category category)
        {
            if (ModelState.IsValid)
            {
                category.TypeCate      = WebConstants.CategoryNews;
                category.SEOUrlRewrite = Helpers.ConvertToUpperLower(category.CategoryName);
                db.Categories.Add(category);
                db.SaveChanges();
                Success(string.Format("Thêm mới <b>{0}</b> thành công, Bạn có thể chọn slide hình ảnh cho <b>{0}</b>.", category.CategoryName), true);
                //return RedirectToAction("Index");
                return(RedirectToAction("Index", "BlogCategories"));
            }

            return(View(category));
        }
        public ActionResult Create([Bind(Include = "CategoryID,CategoryName,Parent,DisplayMenu,IsActive,Sort,TypeCate,SEOTitle,SEOUrlRewrite,SEOKeywords,SEOMetadescription")] Category category)
        {
            if (ModelState.IsValid)
            {
                category.Parent        = 0;
                category.TypeCate      = WebConstants.CategoryProduct;
                category.SEOUrlRewrite = Helpers.ConvertToUpperLower(category.CategoryName);
                db.Categories.Add(category);
                db.SaveChanges();
                Success(string.Format("Thêm mới <b>{0}</b> thành công.", category.CategoryName), true);
                //return RedirectToAction("Index");
                return(RedirectToAction("Edit", "Categories", new { id = category.CategoryID, Area = "Quantri" }));
            }

            return(View(category));
        }
Exemple #10
0
        public string DeleteFile(string file)
        {
            System.Diagnostics.Debug.WriteLine("DeleteFile");
            //    var req = HttpContext.Current;
            System.Diagnostics.Debug.WriteLine(file);

            string fullPath = Path.Combine(StorageRoot, file);

            System.Diagnostics.Debug.WriteLine(fullPath);
            System.Diagnostics.Debug.WriteLine(System.IO.File.Exists(fullPath));
            string thumbPath  = "/" + file.Remove(file.Length - 4, 4) + ".80x80.jpg";
            string partThumb1 = Path.Combine(StorageRoot, "_thumbs");
            string partThumb2 = Path.Combine(partThumb1, file.Remove(file.Length - 4, 4) + ".80x80.jpg");

            System.Diagnostics.Debug.WriteLine(partThumb2);
            System.Diagnostics.Debug.WriteLine(System.IO.File.Exists(partThumb2));
            if (System.IO.File.Exists(fullPath))
            {
                //delete thumb
                if (System.IO.File.Exists(partThumb2))
                {
                    System.IO.File.Delete(partThumb2);
                }
                System.IO.File.Delete(fullPath);


                //GalleryDetail g = db.GalleryDetails.Where(q => q.ImageURL.Equals(file)).First();
                //db.GalleryDetails.Remove(g);
                //db.SaveChanges();

                var img = db.ProductImages.FirstOrDefault(q => q.URLImage.Equals(file));
                db.ProductImages.Remove(img);
                db.SaveChanges();

                string succesMessage = "Ok";

                return(succesMessage);
            }
            //string pathimg = "media/upload/" + file;


            string failMessage = "Error Delete";

            return(failMessage);
        }
        public ActionResult Create([Bind(Include = "CustomerID,CustomerName,CustomerImage,CustomerContent,IsActive,Created")] Customer customer,
                                   HttpPostedFileBase HinhAnh)
        {
            if (ModelState.IsValid)
            {
                var allowedExtensions = new[] {
                    ".Jpg", ".png", ".jpg", "jpeg"
                };
                if (HinhAnh == null)
                {
                    customer.CustomerImage = "NoImage.png";
                }
                else
                {
                    var fileName = Path.GetFileName(HinhAnh.FileName);

                    var ext = Path.GetExtension(HinhAnh.FileName);
                    if (allowedExtensions.Contains(ext))                             //check what type of extension
                    {
                        string name   = Path.GetFileNameWithoutExtension(fileName);  //getting file name without extension
                        string myfile = name + "_" + DateTime.Now.Millisecond + ext; //appending the name with id
                                                                                     // store the file inside ~/project folder(Img)

                        var path = Path.Combine(Server.MapPath(WebConstants.imgLogoCust), myfile);
                        //var dir = Directory.CreateDirectory(path);
                        //HinhAnh.SaveAs(Path.Combine(path, myfile));

                        customer.CustomerImage = myfile;
                        HinhAnh.SaveAs(path);
                    }
                    else
                    {
                        ViewBag.message = "Please choose only Image file";
                    }
                }
                customer.Created = DateTime.Now;
                db.Customers.Add(customer);
                db.SaveChanges();
                Success(string.Format("Thêm mới Logo <b>{0}</b> thành công.", customer.CustomerName), true);
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Exemple #12
0
        public JsonResult ClearCatalogue(int?id)
        {
            PhotoLibraryLst cate = db.PhotoLibraryLsts.Find(id);
            //Xóa hình ảnh đã tồn tại, trừ hình ảnh mặc định.

            string fullPath = Request.MapPath(WebConstants.PhotoLib + "/" + cate.URLImage);

            if (System.IO.File.Exists(fullPath))
            {
                System.IO.File.Delete(fullPath);
            }
            db.PhotoLibraryLsts.Remove(cate);
            db.SaveChanges();
            return(this.Json(
                       "OK", JsonRequestBehavior.AllowGet
                       ));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(View("NotFound", "Home"));
            }
            ProjectViewModel model = new ProjectViewModel();

            model.detail                 = db.Products.Where(p => p.IsActive == true && p.IsProduct == false && p.ProductID == id).FirstOrDefault();
            model.detail.CountView       = model.detail.CountView + 1;
            db.Entry(model.detail).State = EntityState.Modified;
            db.SaveChanges();
            model.lstCategory = db.Categories.Where(c => c.IsActive == true && c.TypeCate == WebConstants.CategoryProduct).ToList();
            model.lstImages   = db.ProductImages.Where(i => i.ProductID == id).ToList();
            var cateid = db.Products.Where(p => p.IsActive == true && p.IsProduct == false && p.ProductID == id).FirstOrDefault().CategoryID;

            model.lstProjects1 = db.Products.Where(p => p.IsActive == true && p.IsProduct == false && p.CategoryID == cateid && p.ProductID != id).OrderByDescending(p => p.ProductID).Take(4).ToList();


            return(View(model));
        }
Exemple #14
0
        public ActionResult Create([Bind(Include = "UserID,UserName,HashPass,Active,Created,CreatedBy")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CreatedBy = new SelectList(db.Users, "UserID", "UserName", user.CreatedBy);
            return(View(user));
        }