コード例 #1
0
        public virtual ActionResult ListUser(string slug, int page, int size)
        {
            var photos = _context.FindPhotosByUserSlug(slug, page, size);

            var model = MapToViewModel(photos);

            return(PartialView(Views.List, model));
        }
コード例 #2
0
        public virtual ActionResult Delete(int id)
        {
            var user = _context.FindById <UserModel>(id);

            if (user == null)
            {
                return(HttpNotFound());
            }

            var photos = _context.FindPhotosByUserSlug(user.Slug, 1, int.MaxValue);

            foreach (var photo in photos)
            {
                var userPhotoActions = _context.FindUserPhotoActionsByPhotoId(photo.PhotoId);
                var comments         = _context.FindCommentsByPhotoId(photo.PhotoId);

                foreach (var userPhotoAction in userPhotoActions)
                {
                    _context.Delete(userPhotoAction);
                    _context.SaveChanges();
                }

                foreach (var comment in comments)
                {
                    _context.Delete(comment);
                    _context.SaveChanges();
                }

                _context.Delete(photo);
                _context.SaveChanges();
            }

            _context.Delete(user);
            _context.SaveChanges();

            return(RedirectToAction(T4Routes.User.Manage()));
        }