public ActionResult Create([Bind(Include = "Id,Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
        public ActionResult Create([Bind(Include = "Id,Email,Address,Phone")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                db.Contacts.Add(contact);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(contact));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "Id,Name")] UserType userType)
        {
            if (ModelState.IsValid)
            {
                db.UserTypes.Add(userType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userType));
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "Id,Title,Image,About")] Blog blog, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                blog.Image = Comman.WorkWithFile.Upload("~/Uploads/", file);
                db.Blogs.Add(blog);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(blog));
        }
Пример #5
0
        public ActionResult Create([Bind(Include = "Id,Name,Surname,About,Image")] Fermer fermer, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                fermer.Image = Comman.WorkWithFile.Upload("~/Uploads/", file);
                db.Fermers.Add(fermer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(fermer));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "Id,Name,About,Image")] History history, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                history.Image = Comman.WorkWithFile.Upload("~/Uploads/", file);
                db.Histories.Add(history);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(history));
        }
Пример #7
0
        public ActionResult Create([Bind(Include = "Id,Name,Surname,UserTypeId,Email,Password")] User user)
        {
            user.Id = db.Users.LastOrDefault().Id + 1;
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserTypeId = new SelectList(db.UserTypes, "Id", "Name", user.UserTypeId);
            return(View(user));
        }
Пример #8
0
        public ActionResult Create([Bind(Include = "Id,Name,CategoryId,About,Price,Description,BoxOrNot")] Product product, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                product.Image = Comman.WorkWithFile.Upload("~/Uploads/", file);
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", product.CategoryId);
            return(View(product));
        }
        public ActionResult Create([Bind(Include = "id,Name,Image,Size,ProductID")] BoxContain boxContain, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                boxContain.Image = Comman.WorkWithFile.Upload("~/Uploads", file);
                db.BoxContains.Add(boxContain);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductID = new SelectList(db.Products, "Id", "Name", boxContain.ProductID);
            return(View(boxContain));
        }
Пример #10
0
 public ActionResult PostComment(string text, int id)
 {
     db.Comments.Add(new Comment {
         BlogDate = DateTime.Now, BlogContent = text, BlogId = id
     });
     db.SaveChanges();
     return(View("Detail", db.Blogs.Include("Comments").Where(m => m.Id == id).FirstOrDefault()));
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Subscribe subscribe = db.Subscribes.Find(id);

            db.Subscribes.Remove(subscribe);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #12
0
 public ActionResult Subscribe(string email)
 {
     if (email != null && email.Length > 4 && email.Contains("@"))
     {
         db.Subscribes.Add(new Subscribe()
         {
             Email = email
         });
         db.SaveChanges();
         return(Json(new { message = "You are subscribed" }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { message = "insert correct email" }, JsonRequestBehavior.AllowGet));
     }
 }