void ReleaseDesignerOutlets()
        {
            if (AboutImage != null)
            {
                AboutImage.Dispose();
                AboutImage = null;
            }

            if (AboutImageView != null)
            {
                AboutImageView.Dispose();
                AboutImageView = null;
            }

            if (AboutTextView != null)
            {
                AboutTextView.Dispose();
                AboutTextView = null;
            }

            if (copyright != null)
            {
                copyright.Dispose();
                copyright = null;
            }
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "id,about_keyName,about_main_img")] About about, HttpPostedFileBase about_main_img, List <string> content, List <string> langlist, List <HttpPostedFileBase> proj_image)
        {
            if (ModelState.IsValid)
            {
                Random random       = new Random();
                int    randomNumber = random.Next(0, 100000);
                int    randomKey    = random.Next(0, 1000000);
                var    filename     = Path.GetFileName(about_main_img.FileName);
                var    src          = Path.Combine(Server.MapPath("~/Uploads/"), randomNumber + filename);
                about_main_img.SaveAs(src);
                about.about_main_img = "/Uploads/" + randomNumber + filename;
                about.about_keyName  = randomKey.ToString();
                db.Abouts.Add(about);
                db.SaveChanges();
                int i = 0;
                foreach (string item in content)
                {
                    Keystring newkey = new Keystring();
                    newkey.keyName = randomKey.ToString();
                    newkey.content = item;
                    int lang = Convert.ToInt16(langlist[i]);
                    newkey.language_id = lang;
                    db.Keystrings.Add(newkey);
                    db.SaveChanges();
                    i++;
                }
                foreach (var item in proj_image)
                {
                    if (item != null)
                    {
                        AboutImage aboutimg = new AboutImage();
                        var        imgname  = Path.GetFileName(item.FileName);
                        var        imgsrc   = Path.Combine(Server.MapPath("~/Uploads/"), randomKey + imgname);
                        item.SaveAs(imgsrc);
                        aboutimg.about_img = "/Uploads/" + randomKey + imgname;

                        db.AboutImages.Add(aboutimg);
                        db.SaveChanges();
                    }
                    else
                    {
                        return(Content("error"));
                    }
                }
                return(RedirectToAction("Index"));
            }

            return(View(about));
        }