public ActionResult DeleteMomentPhoto() { int postcode = int.Parse(Request.Form["postcode"].ToString()); string usrname = Request.Form["user"].ToString(); momentPhotoDal dal = new momentPhotoDal(); dal.momentPhotoLst.RemoveRange(dal.momentPhotoLst.Where(x => x.postcode == postcode)); try { dal.SaveChanges(); } catch (Exception e) { } return(RedirectToAction("MomentView", "User")); }
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")); }