Пример #1
0
        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*/);
        }
Пример #2
0
        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));
        }
Пример #3
0
        public ActionResult GalleryList()
        {
            var galleryList = new List <GalleryViewModel>();

            foreach (var gallery in repo.All())
            {
                galleryList.Add(EntityModelMapper.EntityToModel(gallery));
            }


            return(PartialView("_GalleryListView", galleryList));
        }
Пример #4
0
        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));
        }
Пример #5
0
        // 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));
        }
Пример #6
0
        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));
        }
Пример #7
0
        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));
        }
Пример #8
0
        public ActionResult Edit(int id)
        {
            var model = new PictureViewModel();

            var picFromDB = repo.ByID(id);

            if (picFromDB != null)
            {
                model = EntityModelMapper.EntityToModel(picFromDB);
            }

            return(View(model));
        }
Пример #9
0
        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));
        }
Пример #10
0
        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"));
            }
        }
Пример #11
0
        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));
        }
Пример #12
0
        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));
        }
Пример #13
0
        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"));
        }
Пример #14
0
        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"));
        }
Пример #15
0
        public ActionResult Details(PictureViewModel picture)
        {
            var pictureModel = EntityModelMapper.EntityToModel(repo.ByID(picture.id));

            return(View(pictureModel));
        }
Пример #16
0
        public ActionResult Details(PhotoModel photo)
        {
            PhotoModel photoToDisplay = EntityModelMapper.EntityToModel(PhotoRepo.GetPhoto(photo.PhotoModelId));

            return(View(photoToDisplay));
        }
Пример #17
0
        public ActionResult Details(int id)//this id has to match the routeconfig id name!
        {
            UserModel userToShow = EntityModelMapper.EntityToModel(UserRepository.GetUser(id));

            return(View(userToShow));
        }