コード例 #1
0
ファイル: PhotoController.cs プロジェクト: ivanprgomet-ip/mvc
        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
ファイル: PhotoController.cs プロジェクト: ivanprgomet-ip/mvc
        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
ファイル: UserController.cs プロジェクト: ivanprgomet-ip/mvc
        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
ファイル: AlbumController.cs プロジェクト: ivanprgomet-ip/mvc
        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
ファイル: UserController.cs プロジェクト: ivanprgomet-ip/mvc
        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
ファイル: PhotoController.cs プロジェクト: ivanprgomet-ip/mvc
        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
ファイル: PhotoController.cs プロジェクト: ivanprgomet-ip/mvc
        public ActionResult Details(PhotoModel photo)
        {
            PhotoModel photoToDisplay = EntityModelMapper.EntityToModel(PhotoRepo.GetPhoto(photo.PhotoModelId));

            return(View(photoToDisplay));
        }
コード例 #17
0
ファイル: UserController.cs プロジェクト: ivanprgomet-ip/mvc
        public ActionResult Details(int id)//this id has to match the routeconfig id name!
        {
            UserModel userToShow = EntityModelMapper.EntityToModel(UserRepository.GetUser(id));

            return(View(userToShow));
        }