//[ValidateAntiForgeryToken] public test1.Models.Gallery AddPhoto(test1.Models.Gallery Passedphoto) { // test1.Models.Gallery Passedphoto = new test1.Models.Gallery(); // Passedphoto.Id = Id; Passedphoto.FirstTime = false; if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Content/Images/"), fileName); file.SaveAs(path); //ViewBag.Message = ""; Passedphoto.StatusMessage = ""; Passedphoto.Tmp_Ph_Path = "/Content/Images/" + fileName; } else { Passedphoto.StatusMessage = "خطا در عکس انتخابی"; } } else { Passedphoto.StatusMessage = "لطفا عکسی را انتخاب نمایید"; } //return RedirectToAction("Gallery", "Home", Passedphoto); return(Passedphoto); }
public ActionResult NewGallery(test1.Models.Gallery model) { bool TheResult = false; if (ModelState.IsValid) { Connection.Connection con = new Connection.Connection(); if (User.Identity.GetUserId() != null) { string[] words = model.Ga_Deleteable.Split(' '); foreach (string word in words) { model.Photoes.RemoveAt(Int32.Parse(word)); } TheResult = con.AddGallery(model); } } if (TheResult == true) { return(RedirectToAction("Index", "Manage", new { Message = Models.ManageMessageId.AddGallerySuccess })); } else { return(View()); } }