public ActionResult Create(PhotoModel photo, HttpPostedFileBase[] filesToBeUploaded) { //why is the photo id and album id same? int albumId = photo.PhotoModelId; AlbumModel album = EntityModelMapper.EntityToModel(AlbumRepo.Get(albumId)); foreach (var file in filesToBeUploaded) { //set important properties of the new photo object PhotoModel currentPhoto = new PhotoModel() { //PhotoId = Guid.NewGuid(), Name = photo.Name, FileName = file.FileName, DateCreated = DateTime.Now, Description = "[no description set]", UploadedBy = album.User.Username, Comments = new List <CommentModel>(), }; //physically saves copie(s) of the photos to the path specified file.SaveAs(Server.MapPath("~/UsersData/" + album.User.Username + "/" + album.Name + "/" + file.FileName)); //saves the photo object to the album object //todo: should not this be saved to the static list of a users album photos immediately? album.Photos.Add(currentPhoto); } ; return(RedirectToAction("Index", "Home")); //return PartialView("_Photos",/*allphotos*/); }
public ActionResult Show(GalleryViewModel model) { var pictures = new List <PictureViewModel>(); var picturesFromDB = repo.All().Where(x => x.GalleryID == model.id); foreach (var pic in picturesFromDB) { pictures.Add(EntityModelMapper.EntityToModel(pic)); } ViewBag.GalleryName = model.GalleryName; return(View(pictures)); }
public ActionResult GalleryList() { var galleryList = new List <GalleryViewModel>(); foreach (var gallery in repo.All()) { galleryList.Add(EntityModelMapper.EntityToModel(gallery)); } return(PartialView("_GalleryListView", galleryList)); }
public ActionResult Index() { List <PhotoEntity> photoEntities = PhotoRepo.RetrieveAll(); List <PhotoModel> photoModels = new List <PhotoModel>(); foreach (var photoEntity in photoEntities) { photoModels.Add(EntityModelMapper.EntityToModel(photoEntity)); } return(View(photoModels)); }
// GET: Home public ActionResult Index() { var newestPictures = new List <PictureViewModel>(); var picturesFromDB = repo.All().OrderByDescending(x => x.DatePosted).Take(5).ToList(); foreach (var pic in picturesFromDB) { newestPictures.Add(EntityModelMapper.EntityToModel(pic)); } return(View(newestPictures)); }
public ActionResult Index() { List <UserEntity> userEntities = UserRepository.RetrieveAll(); List <UserModel> userModels = new List <UserModel>(); foreach (var userEntity in userEntities) { userModels.Add(EntityModelMapper.EntityToModel(userEntity)); } return(View(userModels)); }
public ActionResult Index() { List <AlbumEntity> albumEntities = AlbumRepo.GetAll(); List <AlbumModel> albumModels = new List <AlbumModel>(); foreach (var albumEntity in albumEntities) { albumModels.Add(EntityModelMapper.EntityToModel(albumEntity)); } return(View(albumModels)); }
public ActionResult Edit(int id) { var model = new PictureViewModel(); var picFromDB = repo.ByID(id); if (picFromDB != null) { model = EntityModelMapper.EntityToModel(picFromDB); } return(View(model)); }
public ActionResult Comments(int pictureID) { var comments = new List <CommentViewModel>(); var commentsFromDB = repo.All().Where(x => x.PictureID == pictureID); foreach (var comment in commentsFromDB) { comments.Add(EntityModelMapper.EntityToModel(comment)); } return(PartialView(comments)); }
public ActionResult Login(UserModel userModel) { UserModel authenticatedUser = EntityModelMapper.EntityToModel( UserRepository.RetrieveLoggedInUser( userModel.Username, userModel.Password)); if (authenticatedUser != null) { return(Content("Successfull Login")); } else { return(Content("Login failed")); } }
public ActionResult Details(PhotoModel photo, string comment) { PhotoModel photoToCommentOn = EntityModelMapper.EntityToModel(PhotoRepo.GetPhoto(photo.PhotoModelId)); CommentModel newComment = new CommentModel() { //CommentId = Guid.NewGuid(), Comment = comment, DateCreated = DateTime.Now, //Photo = photo, }; photoToCommentOn.Comments.Add(newComment); return(View(photoToCommentOn)); }
public ActionResult Index() { var galleries = new List <GalleryViewModel>(); var galleriesFromDB = repo.All(); if (galleriesFromDB != null) { foreach (var gallery in galleriesFromDB) { var galleryToAdd = EntityModelMapper.EntityToModel(gallery); galleries.Add(galleryToAdd); } } return(View(galleries)); }
public ActionResult Index() { if (User.Identity.IsAuthenticated) { var identity = (ClaimsIdentity)User.Identity; var sid = identity.Claims.First(x => x.Type == ClaimTypes.Sid); int userID = int.Parse(sid.Value); var userFromDB = repo.ByID(userID); if (userFromDB != null) { var user = EntityModelMapper.EntityToModel(userFromDB); return(View(user)); } } return(RedirectToAction("Login", "Auth")); }
public ActionResult ViewGallery(int?id) { if (id == null) { return(RedirectToAction("Index")); } GalleryViewModel galleryToView = null; var galleryID = (int)id; galleryToView = EntityModelMapper.EntityToModel(repo.ByID(galleryID)); if (galleryToView != null) { return(View(galleryToView)); } return(RedirectToAction("Index")); }
public ActionResult Details(PictureViewModel picture) { var pictureModel = EntityModelMapper.EntityToModel(repo.ByID(picture.id)); return(View(pictureModel)); }
public ActionResult Details(PhotoModel photo) { PhotoModel photoToDisplay = EntityModelMapper.EntityToModel(PhotoRepo.GetPhoto(photo.PhotoModelId)); return(View(photoToDisplay)); }
public ActionResult Details(int id)//this id has to match the routeconfig id name! { UserModel userToShow = EntityModelMapper.EntityToModel(UserRepository.GetUser(id)); return(View(userToShow)); }