Exemplo n.º 1
0
 public ActionResult Ekle(MakaleAddViewModel model)
 {
     if (model.PictureUpload != null)
     {
         //string name = Path.GetFileNameWithoutExtension(model.PictureUpload.FileName);
         //string ext = Path.GetExtension(model.PictureUpload.FileName);
         ////Resim upload edilecek.
         //name = name.Replace(" ", "");
         string filename  = model.PictureUpload.FileName;
         string imagePath = Server.MapPath("/images/" + filename);
         model.PictureUpload.SaveAs(imagePath);
         //Makale eklenecek.
         Article yeni = new Article();
         yeni.Title      = model.Title;
         yeni.Summary    = model.Summary;
         yeni.Content    = model.Content;
         yeni.Picture    = filename;
         yeni.CategoryId = model.CategoryId;
         //yeni.UserId = HttpContext.User.Identity.GetUserId();
         yeni.UserId = "55b5fccd-fbd5-4f3a-9fc0-b4b0714cc96d";
         if (repoM.Add(yeni))
         {
             return(RedirectToAction("Index"));
         }
         return(View(model));
     }
     return(View());
 }
Exemplo n.º 2
0
 public ActionResult Ekle(MakaleAddViewModel model)
 {
     if (model.PictureUpload != null)
     {
         string filename  = model.PictureUpload.FileName;
         string imagePath = Server.MapPath("/images/" + filename);
         model.PictureUpload.SaveAs(imagePath);
         Article yeni = new Article();
         yeni.Title      = model.Title.Substring(0, 1).ToUpper() + model.Title.Substring(1);
         yeni.Summary    = model.Summary.Substring(0, 1).ToUpper() + model.Summary.Substring(1);
         yeni.Content    = model.Content;
         yeni.Picture    = filename;
         yeni.CategoryId = model.CategoryId;
         yeni.UserId     = HttpContext.User.Identity.GetUserId();
         if (repoM.Add(yeni))
         {
             return(RedirectToAction("Index"));
         }
         return(View(model));
     }
     return(View());
 }