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 void CreatePhoto(Photo photo) { PhotoPO photoPO = photo.ToPhotoPO(); photoPO.CreatedOn = DateTime.Now.ToUniversalTime(); Database.GetCollection <PhotoPO>(Collections.Photos).Save(photoPO); }
public static PhotoPO PhotoDOtoPO(PhotoDO from) { PhotoPO to = new PhotoPO(); to.PhotoID = from.PhotoID; to.PhotoName = from.PhotoName; to.Height = from.Height; to.Width = from.Width; to.ExtensionType = from.ExtensionType; to.Size = from.Size; to.DateCreated = from.DateCreated; to.Photo = from.Photo; to.Byte = from.Byte; to.AlbumID = from.AlbumID; to.AlbumName = from.AlbumName; return(to); }
public ActionResult Upload(HttpPostedFileBase file, PhotoPO form) { ActionResult response = null; if (Session["RoleID"] != null && (byte)Session["RoleID"] == 3) { if (ModelState.IsValid) { try { if (file.ContentLength > 0) { string fileName = Path.GetFileName(file.FileName); string path = Path.Combine(Server.MapPath("~/Pictures"), fileName); string relativePath = "/" + path.Replace(Server.MapPath("/"), "").Replace("\\", "/"); file.SaveAs(path); form.Photo = relativePath; form.DateCreated = DateTime.Now; _dataAccess.AddPhoto(PhotoMapper.PhotoPOtoDO(form)); response = RedirectToAction("ViewAllPhotos", "Photo"); } else { response = View(form); } } catch (Exception ex) { LogFile.DataFile(ex: ex); throw ex; } } } else { TempData["Statement"] = "Please contact Admin to gain permissions to the page you are requesting."; response = RedirectToAction("Index", "Home"); } return(response); }
public void SetBackgroundImageTempData() { int photoID; List <PhotoAlbumDO> junctionList = new List <PhotoAlbumDO>(); try { junctionList = _dataAccess.ReadAllJunctions(); PhotoAlbumBLO photoAlbumBLO = new PhotoAlbumBLO(); photoID = photoAlbumBLO.PhotoInMostAlbums(PhotoAlbumMapper.ListPhotoAlbumDOtoPO(junctionList)); PhotoPO mostCommonPhoto = PhotoMapper.PhotoDOtoPO(_photoDataAccess.ReadPhotoById(photoID)); Session["BackgroundImageLocation"] = mostCommonPhoto.Photo; } catch (Exception ex) { LogFile.DataFile(ex: ex); } finally { } }