public ActionResult MomentView() { MomentPhotoView mpv = new MomentPhotoView(); momentPhotoDal mp = new momentPhotoDal(); List <momentPhoto> curr = new List <momentPhoto>(); int mid; try { mid = int.Parse(Request.Form["mid"].ToString()); }catch (Exception e) { mid = int.Parse(Session["LastmMid"].ToString()); } int momentId = mid; Session["LastmMid"] = mid; curr = (from x in mp.momentPhotoLst where momentId.Equals(x.mId) select x).ToList <momentPhoto>(); mpv.momentphotos = curr; mpv.photo = "moment"; return(View(mpv)); }
public ActionResult MomentView(int id) { mpv = new MomentPhotoView(); momentPhotoDal mp = new momentPhotoDal(); List <momentPhoto> curr = new List <momentPhoto>(); int momentId = id; mid = id; Session["LastmMid"] = id; curr = (from x in mp.momentPhotoLst where momentId.Equals(x.mId) select x).ToList <momentPhoto>(); mpv.momentphotos = curr; mpv.photo = "moment"; return(View(mpv)); }
public ActionResult AddPhoto(IEnumerable <HttpPostedFileBase> imageModel) { byte[] data; using (Stream inputStram = Request.Files[0].InputStream) { MemoryStream memorystram = inputStram as MemoryStream; if (memorystram == null) { memorystram = new MemoryStream(); inputStram.CopyTo(memorystram); } momentPhotoDal mpd1 = new momentPhotoDal(); momentPhoto mp = new momentPhoto(); data = memorystram.ToArray(); mp.mId = int.Parse(Session["LastmMid"].ToString()); mp.photo = data; mp.username = Session["CurrentUsername"].ToString(); mpd1.momentPhotoLst.Add(mp); mpd1.SaveChanges(); ViewData["photo"] = "Photo Added"; } mpv = new MomentPhotoView(); momentPhotoDal mp1 = new momentPhotoDal(); List <momentPhoto> curr = new List <momentPhoto>(); int momentId = int.Parse(Session["LastmMid"].ToString()); curr = (from x in mp1.momentPhotoLst where momentId.Equals(x.mId) select x).ToList <momentPhoto>(); mpv.momentphotos = curr; mpv.photo = "moment"; return(RedirectToAction("UserMoments", "User")); }