public ActionResult UpdatePhoto(PhotoPO form) { ActionResult response = null; if (Session["RoleID"] != null && (byte)Session["RoleId"] == 3) { if (ModelState.IsValid) { try { _dataAccess.UpdatePhoto(PhotoMapper.PhotoPOtoDO(form)); response = RedirectToAction("ViewAllPhotos", "Photo"); } catch (Exception ex) { LogFile.DataFile(ex: ex); } finally { } } else { response = View(form); } } else { TempData["Statement"] = "Please contact Admin to gain permissions to the page you are requesting."; response = RedirectToAction("Index", "Home"); } return(response); }
public ActionResult Update(PhotosPO photos) { //Defaults redirect to index of photos controller passing albumId. ActionResult oResult = RedirectToAction("Index", "Photos", new { albumId = photos.AlbumId }); if (ModelState.IsValid) { try { //Passing photo object and photo location to use in stored procedure. dataAccess.UpdatePhoto(PhotosMapper.MapPoToDO(photos, photos.PhotoLocation)); TempData["Message"] = "Photo successfully updated."; } catch (Exception ex) { //Logs exception using exceptionLog class. exceptionLog.ExceptionLog("Critical", ex.Message, "PhotosController", "Update", ex.StackTrace); oResult = View(new { albumId = photos.AlbumId }); } } else { //returns the albumId to the view. oResult = View(new { albumId = photos.AlbumId }); } return(oResult); }