public ActionResult Create([Bind(Exclude = "Image")] Partner partner, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    if (Extensions.Extensions.CheckImageType(Image) && Extensions.Extensions.CheckImageSize(Image, 10))
                    {
                        partner.Image = Extensions.Extensions.SaveImage(Server.MapPath("~/Public/images"), Image);

                        db.Partners.Add(partner);
                        db.SaveChanges();

                        return(RedirectToAction("Index", "Partner"));
                    }
                    else
                    {
                        ModelState.AddModelError("Image", "The type of image is incorrect or the size of image is greater than 10 Mb.");
                    }
                }
                else
                {
                    ModelState.AddModelError("Image", "Please choose an image");
                }
            }

            return(View());
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(int?id)
        {
            Contact contact = db.Contacts.Find(id);

            db.Contacts.Remove(contact);
            db.SaveChanges();

            return(RedirectToAction("Index", "Contact"));
        }
Esempio n. 3
0
        public ActionResult Create(NewsTag newsTag)
        {
            if (ModelState.IsValid)
            {
                db.NewsTags.Add(newsTag);
                db.SaveChanges();

                return(RedirectToAction("Index", "NewsTag"));
            }

            return(View());
        }
        public ActionResult Index(Vacation vacation)
        {
            Staff staff = Session["staff"] as Staff;

            if (ModelState.IsValid)
            {
                vacation.StaffID = staff.ID;
                db.Vacations.Add(vacation);
                db.SaveChanges();
                return(View("Index", "Home"));
            }
            return(View());
        }
Esempio n. 5
0
        public ActionResult Index(StaffOrder order)
        {
            if (ModelState.IsValid)
            {
                User user = Session["user"] as User;
                order.UserID = user.ID;
                db.StaffOrders.Add(order);

                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }

            db.SaveChanges();
            return(View());
        }
        public ActionResult Edit([Bind(Exclude = "Image")] Team team, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    if (Extensions.Extensions.CheckImageType(Image) && Extensions.Extensions.CheckImageSize(Image, 10))
                    {
                        team.Image = Extensions.Extensions.SaveImage(Server.MapPath("~/Public/images"), Image);


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

                        return(RedirectToAction("Index", "Team"));
                    }
                    else
                    {
                        ModelState.AddModelError("Image", "The type of image is incorrect or the size of image is greater than 10 Mb.");
                    }
                }
                else
                {
                    ModelState.AddModelError("Image", "Please choose an image");
                }
            }
            return(View());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Mesagge mesagge = db.Mesagges.Find(id);

            db.Mesagges.Remove(mesagge);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            StudioOrder studioOrder = db.StudioOrders.Find(id);

            db.StudioOrders.Remove(studioOrder);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 9
0
        public ActionResult CreateComment(string content, int blogID)
        {
            User user = Session["user"] as User;

            BlogComment comment = new BlogComment
            {
                Content     = content,
                UserID      = user.ID,
                BlogID      = blogID,
                CommentDate = DateTime.Now
            };

            db.BlogComments.Add(comment);
            db.SaveChanges();
            comment.User = user;

            return(PartialView("_PartialComment", comment));
        }
        public ActionResult Create([Bind(Include = "ID,Firstname,Lastname,AsPhotograph,AsVideograph,Email,Password")] Staff staff)
        {
            if (ModelState.IsValid)
            {
                if (db.Staffs.Where(s => s.Email.ToUpper().Trim() == staff.Email.ToUpper().Trim()) == null)
                {
                    staff.Password = Crypto.HashPassword(staff.Password);
                    db.Staffs.Add(staff);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("Email", "This Email is already exist");
                }
            }

            return(View(staff));
        }
Esempio n. 11
0
        public ActionResult DeleteConfirmed(int?id)
        {
            NewsComment newsComment = db.NewsComments.Find(id);


            db.NewsComments.Remove(newsComment);
            db.SaveChanges();

            return(RedirectToAction("Index", "NewsComments"));
        }
        public ActionResult DeleteConfirmed(int?id)
        {
            BlogComment blogComment = db.BlogComments.Find(id);


            db.BlogComments.Remove(blogComment);
            db.SaveChanges();

            return(RedirectToAction("Index", "BlogComments"));
        }
        public ActionResult Register(User user)
        {
            if (ModelState.IsValid)
            {
                if (db.Users.Where(u => u.Email.ToUpper().Trim() == user.Email.ToUpper().Trim()).FirstOrDefault() == null)
                {
                    db.Users.Add(new User
                    {
                        Email     = user.Email,
                        Firstname = user.Firstname,
                        Lastname  = user.Lastname,
                        Password  = Crypto.HashPassword(user.Password)
                    });
                    db.SaveChanges();
                    return(RedirectToAction("Login"));
                }
                else
                {
                    ModelState.AddModelError("Email", "This email is already exists");
                }
            }

            return(View());
        }
Esempio n. 14
0
        public ActionResult Contact(Mesagge mesagge)
        {
            if (ModelState.IsValid)
            {
                db.Mesagges.Add(mesagge);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ContactViewModel vm = new ContactViewModel
            {
                Contact       = db.Contacts.First(),
                ContactHeader = db.ContactHeaders.First(),
                Mesagge       = mesagge
            };

            return(View(vm));
        }
        public async Task <ActionResult> Create([Bind(Exclude = "Image")] Blog blog, HttpPostedFileBase Image, IEnumerable <int> BlogTags)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    if (Extensions.Extensions.CheckImageType(Image) && Extensions.Extensions.CheckImageSize(Image, 10))
                    {
                        blog.Image     = Extensions.Extensions.SaveImage(Server.MapPath("~/Public/images"), Image);
                        blog.CreatedAt = blog.UpdatedAt = DateTime.Now;
                        User user = Session["user"] as User;
                        blog.UserID = user.ID;
                        Blog addedBlog = null;

                        Task addedBlogTask = Task.Run(() =>
                        {
                            addedBlog = db.Blogs.Add(blog);
                            db.SaveChanges();
                        });

                        await addedBlogTask;
                        if (BlogTags != null)
                        {
                            foreach (var TagID in BlogTags)
                            {
                                db.BlogToTags.Add(new BlogToTag
                                {
                                    BlogID = addedBlog.ID,
                                    TagID  = TagID
                                });
                                db.SaveChanges();
                            }
                        }

                        db.SaveChanges();

                        return(RedirectToAction("Index", "Blog"));
                    }
                    else
                    {
                        ModelState.AddModelError("Image", "The type of image is incorrect or the size of image is greater than 10 Mb.");
                    }
                }
                else
                {
                    ModelState.AddModelError("Image", "Please choose an image");
                }
            }
            ViewBag.BlogTags = new SelectList(db.BlogTags, "ID", "Tag");
            return(View());
        }
        public async Task <ActionResult> Create([Bind(Exclude = "Image")] News news, HttpPostedFileBase Image, IEnumerable <int> NewsTags)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    if (Extensions.Extensions.CheckImageType(Image) && Extensions.Extensions.CheckImageSize(Image, 10))
                    {
                        news.Image     = Extensions.Extensions.SaveImage(Server.MapPath("~/Public/images"), Image);
                        news.CreatedAt = news.UpdatedAt = DateTime.Now;

                        News addedNews = null;

                        Task addedNewsTask = Task.Run(() =>
                        {
                            addedNews = db.News.Add(news);
                            db.SaveChanges();
                        });

                        await addedNewsTask;
                        if (NewsTags != null)
                        {
                            foreach (var TagID in NewsTags)
                            {
                                db.NewsToTags.Add(new NewsToTag
                                {
                                    NewsID = addedNews.ID,
                                    TagID  = TagID
                                });
                                db.SaveChanges();
                            }
                        }

                        db.SaveChanges();

                        return(RedirectToAction("Index", "Newss"));
                    }
                    else
                    {
                        ModelState.AddModelError("Image", "The type of image is incorrect or the size of image is greater than 10 Mb.");
                    }
                }
                else
                {
                    ModelState.AddModelError("Image", "Please choose an image");
                }
            }
            ViewBag.NewsTags = new SelectList(db.NewsTags, "ID", "Tag");
            return(View());
        }