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)));
        }
示例#2
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);
        }
        public void btnEditPicture_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(hdnId.Value))
            {
                var type = hdnId.Value.Split('=')[0];
                var id   = hdnId.Value.Split('=')[1];

                switch (type)
                {
                case "picture":
                    var myShowArtService = new MyShowArtService(Ioc.GetInstance <IMyShowArtRepository>());
                    var myShowArt        = myShowArtService.GetMyShowArt(new Guid(id));
                    Response.Redirect(LinkBuilder.EditArtLink(myShowArt.ArtId));
                    break;

                case "poster":
                    var myShowPosterService = new MyShowPosterService(Ioc.GetInstance <IMyShowPosterRepository>());
                    var myShowPoster        = myShowPosterService.GetMyShowPoster(new Guid(id));
                    Response.Redirect(LinkBuilder.EditPosterLink(myShowPoster.PosterId));
                    break;
                }
            }
        }
        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);
        }
        private MyShowPoster GetPoster(Guid posterId)
        {
            var myShowPosterService = new MyShowPosterService(Ioc.GetInstance <IMyShowPosterRepository>());

            return((MyShowPoster)myShowPosterService.GetMyShowPoster(posterId));
        }