Esempio n. 1
0
        public ActionResult EditExibition(exibition a)
        {
            if (a.ImageFile != null)
            {
                string             filename   = Path.GetFileNameWithoutExtension(a.ImageFile.FileName);
                string             extension  = Path.GetExtension(a.ImageFile.FileName);
                HttpPostedFileBase postedFile = a.ImageFile;
                int length = postedFile.ContentLength;

                if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
                {
                    if (length <= 1000000)
                    {
                        filename = filename + extension;
                        a.Image  = "~/Exibition/" + filename;
                        filename = Path.Combine(Server.MapPath("~/Exibition/"), filename);
                        a.ImageFile.SaveAs(filename);
                        obj.Entry(a).State = EntityState.Modified;

                        int b = obj.SaveChanges();

                        if (b > 0)
                        {
                            string imagepath = Request.MapPath(Session["image2"].ToString());
                            if (System.IO.File.Exists(imagepath))
                            {
                                System.IO.File.Delete(imagepath);
                            }
                            TempData["upmessage"] = "<script>alert('Data Updated Succesfully')</script>";
                            ModelState.Clear();
                            return(RedirectToAction("Exibition", "Manager"));
                        }
                        else
                        {
                            TempData["updtemessage"] = "<script>alert('Data Not Updated')</script>";
                        }
                    }
                    else
                    {
                        TempData["lengthmessage"] = "<script>alert('Length should be 10 mb')</script>";
                    }
                }
                else
                {
                    TempData["extentionmessage"] = "<script>alert('Format not Supported')</script>";
                }
            }

            return(View());
        }
Esempio n. 2
0
        public ActionResult Create_Exibition(exibition a)
        {
            string             filename   = Path.GetFileNameWithoutExtension(a.ImageFile.FileName);
            string             extension  = Path.GetExtension(a.ImageFile.FileName);
            HttpPostedFileBase postedFile = a.ImageFile;
            int length = postedFile.ContentLength;

            if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
            {
                if (length <= 1000000)
                {
                    filename = filename + extension;
                    a.Image  = "~/Exibition/" + filename;
                    filename = Path.Combine(Server.MapPath("~/Exibition/"), filename);
                    a.ImageFile.SaveAs(filename);
                    obj.exibitions.Add(a);

                    int b = obj.SaveChanges();

                    if (b > 0)
                    {
                        TempData["datamessage"] = "<script>alert('Data Inserted Succesfully')</script>";
                        ModelState.Clear();
                        return(RedirectToAction("Exibition", "Manager"));
                    }
                    else
                    {
                        TempData["dtemessage"] = "<script>alert('Data Not Inserted')</script>";
                    }
                }
                else
                {
                    TempData["lengthmessage"] = "<script>alert('Length should be 10 mb')</script>";
                }
            }
            else
            {
                TempData["extentionmessage"] = "<script>alert('Format not Supported')</script>";
            }


            return(View());
        }
Esempio n. 3
0
        public ActionResult Exibition(exibition a)
        {
            var data = obj.exibitions.ToList();

            return(View(data));
        }
Esempio n. 4
0
        public ActionResult student_Exibition(exibition a)
        {
            var view = obj.exibitions.ToList();

            return(View(view));
        }