public ActionResult Create(PhotoViewModel pvm, HttpPostedFileBase uploadDate) { PhotoServiceClient psc = new PhotoServiceClient(); if (uploadDate != null) { //Image image = new Bitmap(uploadImage.InputStream); string fileName= System.Guid.NewGuid() + ".jpeg"; //ExifReader exifdate = new ExifReader(image); pvm.Photo.AddDate = DateTime.Now.ToString(); pvm.Photo.Image = "/UserImagesBD/" + fileName; //pvm.Photo.Model = exifdate.getExifModel(); //pvm.Photo.CreateDate = exifdate.getExifCDate(); int fileSizeInBytes = uploadDate.ContentLength; MemoryStream target = new MemoryStream(); uploadDate.InputStream.CopyTo(target); byte[] uploadImage = target.ToArray(); psc.upload(fileName, uploadImage); } psc.create(pvm.Photo); return RedirectToAction("Album"); }
public ActionResult Album() { string id = User.Identity.Name; PhotoServiceClient psc = new PhotoServiceClient(); ViewBag.listUserPhoto = psc.finduser(id); return View(); }
public ActionResult Edit(string id) { PhotoServiceClient psc = new PhotoServiceClient(); PhotoViewModel pvm = new PhotoViewModel(); pvm.Photo = psc.find(id); if (!pvm.Photo.UserName.Equals(User.Identity.Name)) return View("NotFound"); ViewBag.Photo = pvm.Photo; return View("Edit", pvm); }
public ActionResult Delete(string id) { PhotoServiceClient psc = new PhotoServiceClient(); PhotoViewModel pvm = new PhotoViewModel(); pvm.Photo = psc.find(id); if (!(User.Identity.Name).Equals(pvm.Photo.UserName)) return View("NotFound"); psc.delete(psc.find(id)); return RedirectToAction("Album"); }
public ActionResult Edit(PhotoViewModel pvm) { PhotoServiceClient psc = new PhotoServiceClient(); psc.edit(pvm.Photo); return RedirectToAction("Album"); }
public ActionResult UsersAlbum(string name) { if (name.Equals(User.Identity.Name)) return RedirectToAction("Album"); PhotoServiceClient psc = new PhotoServiceClient(); ViewBag.UserName = name; ViewBag.listUserPhoto = psc.finduser(name); return View(); }
// // GET: /Photo/ public ActionResult Index() { PhotoServiceClient psc = new PhotoServiceClient(); ViewBag.listPhoto = psc.findall(); ViewBag.UserName = User.Identity.Name; return View(); }