Example #1
0
        protected void btnKaydet_Click(object sender, EventArgs e)
        {
            string durum = "";

            if (fuImage.HasFile)
            {
                FileInfo imgInfo = new FileInfo(fuImage.FileName);                //dosya adı alındı
                string   newimg  = Guid.NewGuid().ToString() + imgInfo.Extension; //resme yeni ad verildi. guid unic bir sayı belirler
                if (newimg != null)
                {
                    fuImage.SaveAs(Server.MapPath("~/images/portfolio/") + newimg);
                    durum = "/images/portfolio/" + newimg;
                }
            }
            if (durum == "")
            {
                durum = "/images/portfolio/bosresim.jfif";
            }
            wr.Insert(new Project
            {
                Title         = txtProjectName.Text,
                ProjeLanguage = txtProjeLanguage.Text,
                ProjeAbout    = txtProjectAbout.Text,
                ProjeImage    = durum
            });
            Response.Redirect("~/AdminPanel/Work/WorkList.aspx");
        }
Example #2
0
 public ActionResult Create(Work work, HttpPostedFileBase image)
 {
     if (ModelState.IsValid)
     {
         if (image != null)
         {
             image.SaveAs(HttpContext.Server.MapPath("~/Content/workimages/") + image.FileName);
             work.Image = "/Content/workimages/" + image.FileName;
         }
         work.Closed = false;
         work.UserId = WebSecurity.CurrentUserId;
         workRepository.Insert(work);
         unitOfWork.Save();
         return(RedirectToAction("Index"));
     }
     return(View(work));
 }