public MyShowThumbnail<IMyShowPoster> GetAnyMyShowPosterForUser(Guid userId)
        {
            var myShowService = new MyShowService(Ioc.GetInstance<IMyShowRepository>());
            var posterService = new PosterService(Ioc.GetInstance<IPosterRepository>());
            var photoService = new PhotoService(Ioc.GetInstance<IPhotoRepository>());

            var myShows = myShowService.GetMyShowsForUser(userId);

            var myShowPosters = GetAllMyShowPosters().Where(x => myShows.Any(y => y.MyShowId == x.MyShowId)).OrderByDescending(z => z.CreatedDate);

            foreach (var myShowPoster in myShowPosters)
            {
                var poster = posterService.GetPoster(myShowPoster.PosterId);
                var photo = photoService.GetPhotoThumbnail(poster.PhotoId);
                if (photo.Thumbnail)
                    return new MyShowThumbnail<IMyShowPoster>(myShowPoster, photo);
            }

            return null;
        }
예제 #2
0
        public MyShowThumbnail <IMyShowPoster> GetAnyMyShowPosterForUser(Guid userId)
        {
            var myShowService = new MyShowService(Ioc.GetInstance <IMyShowRepository>());
            var posterService = new PosterService(Ioc.GetInstance <IPosterRepository>());
            var photoService  = new PhotoService(Ioc.GetInstance <IPhotoRepository>());

            var myShows = myShowService.GetMyShowsForUser(userId);

            var myShowPosters = GetAllMyShowPosters().Where(x => myShows.Any(y => y.MyShowId == x.MyShowId)).OrderByDescending(z => z.CreatedDate);

            foreach (var myShowPoster in myShowPosters)
            {
                var poster = posterService.GetPoster(myShowPoster.PosterId);
                var photo  = photoService.GetPhotoThumbnail(poster.PhotoId);
                if (photo.Thumbnail)
                {
                    return(new MyShowThumbnail <IMyShowPoster>(myShowPoster, photo));
                }
            }

            return(null);
        }
예제 #3
0
        private void DeletePoster(string posterIdStr)
        {
            var posterId = new Guid(posterIdStr);

            var myShowPoster = GetPoster(posterId);
            var myShowPosterId = myShowPoster.MyShowPosterId.ToString();
            var photoId = myShowPoster.Poster.Photo.PhotoId.ToString();
            var filename = myShowPoster.Poster.Photo.FileName.ToString();

            var posterService = new PosterService(Ioc.GetInstance<IPosterRepository>());
            var photoService = new PhotoService(Ioc.GetInstance<IPhotoRepository>());
            var myShowPosterService = new MyShowPosterService(Ioc.GetInstance<IMyShowPosterRepository>());

            using (IUnitOfWork uow = UnitOfWork.Begin())
            {
                var photo = myShowPoster.Poster.Photo;
                var poster = myShowPoster.Poster;

                photoService.Delete(photo);
                posterService.Delete(poster);
                myShowPosterService.Delete(myShowPoster);

                uow.Commit();
            }

            log.WriteLine("Deleted myShowPoster Id: " + myShowPosterId);
            log.WriteLine("Deleted photo Id: " + photoId + "and filename: " + filename);
            log.WriteLine("Deleted picture Id: " + posterId);

            Response.Redirect(LinkBuilder.MyPostersLink(new Guid(hdnShowId.Value)));

        }
예제 #4
0
        public bool CreatePoster(IPhoto photo, Guid? showId)
        {
            bool final = false;
            var posterId = Guid.NewGuid();

            var posterService = new PosterService(Ioc.GetInstance<IPosterRepository>());
            var myShowService = new MyShowService(Ioc.GetInstance<IMyShowRepository>());
            var spService = new MyShowPosterService(Ioc.GetInstance<IMyShowPosterRepository>());

            var userId = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
            var myShowId = myShowService.GetMyShow(showId.Value, userId).MyShowId;

            var date = DateTime.UtcNow;

            Poster p = new Poster
            {
                CreatedDate = DateTime.Now,
                PhotoId = photo.PhotoId,
                PosterId = posterId,
                Notes = photo.Notes,
                UserId = photo.UserId,
                Creator = txtCreator.Text,
                Length = string.IsNullOrEmpty(txtLength.Text) ? 0 : double.Parse(txtLength.Text),
                Width = string.IsNullOrEmpty(txtWidth.Text) ? 0 : double.Parse(txtWidth.Text),
                Total = string.IsNullOrEmpty(txtTotal.Text) ? 0 : int.Parse(txtTotal.Text),
                Number = string.IsNullOrEmpty(txtNumber.Text) ? 0 : int.Parse(txtNumber.Text),
                Technique = txtTechnique.Text,
                Title = txtTitle.Text,
                ShowId = showId
            };

            var combinedSuccess = true;
            bool success = false;

            var photoService = new PhotoService(Ioc.GetInstance<IPhotoRepository>());
            photoService.Save(photo, out success);

            combinedSuccess = combinedSuccess && success;

            posterService.Save(p, out success);

            combinedSuccess = combinedSuccess && success;

            var myShowPoster = new MyShowPoster
            {
                CreatedDate = date,
                UpdatedDate = date,
                MyShowId = myShowId,
                MyShowPosterId = Guid.NewGuid(),
                PosterId = posterId
            };

            spService.Save(myShowPoster, out success);

            combinedSuccess = combinedSuccess && success;

            return combinedSuccess;
        }
예제 #5
0
        //private void BindTicketStubs(Guid userId)
        //{
        //    TicketStubService ticketStubService = new TicketStubService(Ioc.GetInstance<ITicketStubRepository>());

        //    var ticketStubs = ticketStubService.GetTicketStubsByUserId(userId).ToList();

        //    rptTicketStubs.DataSource = ticketStubs;
        //    rptTicketStubs.DataBind();
        //}

        private void BindPosters(Guid userId)
        {
            PosterService posterService = new PosterService(Ioc.GetInstance<IPosterRepository>());

            var posters = posterService.GetByUser(userId);

            //rptPoster.DataSource = posters;
            //rptPoster.DataBind();
        }
        public override void ProcessRequest(HttpContextBase context)
        {
            HttpRequestBase request = context.Request;
            var showIdStr = request.QueryString["s"];
            var userIdStr = request.QueryString["u"];
            HttpResponseBase response = context.Response;

            var final = string.Empty;

            if (EmptyNullUndefined(showIdStr) || EmptyNullUndefined(userIdStr))
            {
                final = GetNoImagesFound();

                response.ContentType = "application/json";
                response.ContentEncoding = Encoding.UTF8;
                response.Write(final);
                response.End();
            }

            var showId = new Guid(showIdStr);
            var userId = new Guid(userIdStr);

            var myShowService = new MyShowService(Ioc.GetInstance<IMyShowRepository>());
            var myShowPosterService = new MyShowPosterService(Ioc.GetInstance<IMyShowPosterRepository>());
            var posterService = new PosterService(Ioc.GetInstance<IPosterRepository>());

            var myShow = myShowService.GetMyShow(showId, userId);
            IList<KeyValuePair<Poster, IMyShowPoster>> posters = new List<KeyValuePair<Poster, IMyShowPoster>>();

            if (myShow != null)
            {
                var myShowPosters = myShowPosterService.GetMyShowPosterByMyShow(myShow.MyShowId);

                myShowPosters.ToList().ForEach(x =>
                {
                    posters.Add(new KeyValuePair<Poster, IMyShowPoster>((Poster)posterService.GetPoster(x.PosterId), x));
                });
            }

            if (posters == null || posters.Count <= 0)
            {
                final = GetNoImagesFound();
            }

            //If there are images and no errors so far then process
            if (string.IsNullOrEmpty(final))
            {
                var json = new ImageJSONifier("records");

                foreach (var a in posters)
                {
                    if (a.Key == null || a.Key.Photo == null) continue;

                    json.Add(new ImageItem
                    {
                        Image = "/images/Shows/" + a.Key.Photo.FileName,
                        Description = a.Key.Notes,
                        Title = a.Key.Photo.NickName,
                        Link = string.Format("DeletePicture.aspx?posid={0}&showId={1}", a.Value.MyShowPosterId.ToString(), showId.ToString())
                    });
                }

                final = json.GetFinalizedJSON();
            }

            response.ContentType = "application/json";
            response.ContentEncoding = Encoding.UTF8;
            response.Write(final);
        }
        public override void ProcessRequest(HttpContextBase context)
        {
            HttpRequestBase request = context.Request;
            var userIdStr = request.QueryString["u"];
            HttpResponseBase response = context.Response;

            var final = string.Empty;

            if (EmptyNullUndefined(userIdStr))
            {
                final = GetNoImagesFound();

                response.ContentType = "application/json";
                response.ContentEncoding = Encoding.UTF8;
                response.Write(final);
                response.End();
            }

            var userId = new Guid(userIdStr);

            var artService = new ArtService(Ioc.GetInstance<IArtRepository>());
            var posterService = new PosterService(Ioc.GetInstance<IPosterRepository>());

            var art = artService.GetArtByUser(userId).Cast<Art>().Where(y => y.Show != null).ToList();
            var posters = posterService.GetByUser(userId).Cast<Poster>().Where(z => z.ShowId != null).ToList();

            //If there are no art or posters then return no images found
            if ((art == null && posters == null) || (art.Count <= 0 && posters.Count <= 0))
            {
                final = GetNoImagesFound();

                response.ContentType = "application/json";
                response.ContentEncoding = Encoding.UTF8;
                response.Write(final);
                response.End();
            }

            var allImages = (from a in art
                             select new ImageItem
                             {
                                 Image = ShowImagesFolder + a.Photo.FileName,
                                 Description = a.Photo.Notes,
                                 Title = a.Photo.NickName,
                                 ShowDate = a.Show.ShowDate.Value
                             }).ToList();

            allImages.AddRange((from p in posters
                                select new ImageItem
                                {
                                    Image = ShowImagesFolder + p.Photo.FileName,
                                    Description = p.Photo.Notes,
                                    Title = p.Photo.NickName,
                                    ShowDate = p.Show.ShowDate.Value
                                }).ToList());

            var json = new ImageJSONifier("records", allImages.OrderBy(y => y.ShowDate));

            final = json.GetFinalizedJSON();

            response.ContentType = "application/json";
            response.ContentEncoding = Encoding.UTF8;
            response.Write(final);
        }