private void DeletePic(string pictureIdStr)
        {
            var pictureId = new Guid(pictureIdStr);

            var myShowArt   = GetPicture(pictureId);
            var myShowArtId = myShowArt.MyShowArtId.ToString();
            var photoId     = myShowArt.Art.Photo.PhotoId.ToString();
            var filename    = myShowArt.Art.Photo.FileName.ToString();

            var artService       = new ArtService(Ioc.GetInstance <IArtRepository>());
            var photoService     = new PhotoService(Ioc.GetInstance <IPhotoRepository>());
            var myShowArtService = new MyShowArtService(Ioc.GetInstance <IMyShowArtRepository>());

            using (IUnitOfWork uow = UnitOfWork.Begin())
            {
                photoService.Delete(myShowArt.Art.Photo);
                artService.Delete(myShowArt.Art);
                myShowArtService.Delete(myShowArt);

                uow.Commit();
            }

            log.WriteLine("Deleted myShowArt Id: " + myShowArtId);
            log.WriteLine("Deleted photo Id: " + photoId + "and filename: " + filename);
            log.WriteLine("Deleted picture Id: " + pictureId);

            Response.Redirect(LinkBuilder.MyPicturesLink(new Guid(hdnShowId.Value)));
        }
        public bool CreateArt(IPhoto photo, Guid?showId)
        {
            bool final = false;
            var  artId = Guid.NewGuid();

            var artService    = new ArtService(Ioc.GetInstance <IArtRepository>());
            var myShowService = new MyShowService(Ioc.GetInstance <IMyShowRepository>());
            var spService     = new MyShowArtService(Ioc.GetInstance <IMyShowArtRepository>());

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

            var date = DateTime.UtcNow;

            Art p = new Art
            {
                CreatedDate = date,
                UpdatedDate = date,
                PhotoId     = photo.PhotoId,
                ArtId       = artId,
                Notes       = photo.Notes,
                UserId      = photo.UserId,
                ShowId      = showId
            };


            var  combinedSuccess = true;
            bool success         = false;

            var photoService = new PhotoService(Ioc.GetInstance <IPhotoRepository>());

            photoService.Save(photo, out success);

            combinedSuccess = combinedSuccess && success;

            artService.Save(p, out success);

            combinedSuccess = combinedSuccess && success;

            var myShowArt = new MyShowArt
            {
                CreatedDate = date,
                UpdatedDate = date,
                MyShowId    = myShowId,
                MyShowArtId = Guid.NewGuid(),
                ArtId       = artId
            };

            spService.Save(myShowArt, 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)
        {
            //System.Threading.Thread.Sleep(4000);
            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);

            MyShowService    myShowService    = new MyShowService(Ioc.GetInstance <IMyShowRepository>());
            MyShowArtService myShowArtService = new MyShowArtService(Ioc.GetInstance <IMyShowArtRepository>());
            ArtService       artService       = new ArtService(Ioc.GetInstance <IArtRepository>());

            var myShow = myShowService.GetMyShow(showId, userId);
            IList <KeyValuePair <Art, IMyShowArt> > art = new List <KeyValuePair <Art, IMyShowArt> >();

            if (myShow != null)
            {
                var myShowArts = myShowArtService.GetMyShowArtByMyShow(myShow.MyShowId);

                myShowArts.ToList().ForEach(x =>
                {
                    art.Add(new KeyValuePair <Art, IMyShowArt>((Art)artService.GetArt(x.ArtId), x));
                });
            }

            if (art == null || art.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 art)
                {
                    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?picid={0}&showId={1}", a.Value.MyShowArtId.ToString(), showId.ToString())
                    });
                }

                final = json.GetFinalizedJSON();
            }

            response.ContentType     = "application/json";
            response.ContentEncoding = Encoding.UTF8;
            response.Write(final);
        }
        private MyShowArt GetPicture(Guid pictureId)
        {
            var myShowArtService = new MyShowArtService(Ioc.GetInstance <IMyShowArtRepository>());

            return((MyShowArt)myShowArtService.GetMyShowArt(pictureId));
        }