Пример #1
0
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            if (EmptyNullUndefined(txtAlbumName.Text) || ddlYearReleased.SelectedValue == "-1")
                return;

            var album = new Album
            {
                AlbumId = Guid.NewGuid(),
                AlbumName = txtAlbumName.Text,
                CreatedDate = DateTime.UtcNow,
                YearReleased = int.Parse(ddlYearReleased.SelectedValue)
            };

            var albumService = new AlbumService(Ioc.GetInstance<IAlbumRepository>());

            bool success;
            albumService.SaveCommit(album, out success);

            if (success)
            {
                var scriptHelper = new ScriptHelper("SuccessAlert", "alertDiv", "You have successfully created an album.");
                Page.RegisterStartupScript(scriptHelper.ScriptName, scriptHelper.GetSuccessScript());
            }
            else
            {
                var scriptHelper = new ScriptHelper("ErrorAlert", "alertDiv", "There was an error, try again later.");
                Page.RegisterStartupScript(scriptHelper.ScriptName, scriptHelper.GetFatalScript());
            }
        }
Пример #2
0
        private IMyShow GetMyShow(string myShowIdStr)
        {
            ResetPanels();

            if (string.IsNullOrEmpty(hdnMyShowId.Value))
            {
                var scriptHelper3 = new ScriptHelper("ErrorAlert", "alertDiv", "There was an error saving your review.");
                Page.RegisterStartupScript(scriptHelper3.ScriptName, scriptHelper3.GetFatalScript());
                return null;
            }

            var myShowService = new MyShowService(Ioc.GetInstance<IMyShowRepository>());

            var myShowId = new Guid(myShowIdStr);

            return myShowService.GetMyShow(myShowId);
        }
Пример #3
0
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            FavoriteVersionService faveService = new FavoriteVersionService(Ioc.GetInstance<IFavoriteVersionRepository>());

            Guid userId = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());

            if (string.IsNullOrEmpty(ddlFavoriteChoice.SelectedValue))
                return;

            Guid setSongId = new Guid(ddlFavoriteChoice.SelectedValue.Split('^')[0]);
            Guid songId = new Guid(ddlFavoriteChoice.SelectedValue.Split('^')[1]);

            var fave = faveService.GetFavoriteVersionByUserIdAndSongId(userId, songId);

            bool success = false;

            if (fave != null)
            {
                using (IUnitOfWork uow = UnitOfWork.Begin())
                {
                    fave.SetSongId = setSongId;
                    fave.UpdatedDate = DateTime.Now;

                    uow.Commit();

                    success = true;
                }
            }
            else
            {
                FavoriteVersion faveVersion = new FavoriteVersion
                {
                    FavoriteVersionId = Guid.NewGuid(),
                    SetSongId = setSongId,
                    SongId = songId,
                    UserId = userId
                };

                faveService.SaveCommit(faveVersion, out success);
            }

            if (success)
            {
                var scriptHelper = new ScriptHelper("SuccessAlert", "alertDiv", "Congratulations you have added a favorite version");
                Page.RegisterStartupScript(scriptHelper.ScriptName, scriptHelper.GetSuccessScript());
                btnChooseAlbum_Click(null, null);
            }
            else
            {
                var scriptHelper = new ScriptHelper("ErrorAlert", "alertDiv", "Sorry an error has occurred saving your favorite version");
                Page.RegisterStartupScript(scriptHelper.ScriptName, scriptHelper.GetFatalScript());
            }
        }
Пример #4
0
        public void btnSubmit_Click(object sender, EventArgs e)
        { 
            ResetPanels();

            bool compiledSuccess = true;

            if (!AnyInputHasFile())
            {
                var scriptHelper = new ScriptHelper("ErrorAlert", "alertDiv", "Please choose a file to upload.");
                Page.RegisterStartupScript(scriptHelper.ScriptName, scriptHelper.GetFatalScript());
                return;
            }

            var errorMessage = string.Empty;

                using (IUnitOfWork uow = UnitOfWork.Begin())
                {
                    var fileList = GetFileList();

                    foreach (var file in fileList)
                    {
                        var validator = ProcessFile(file);

                        compiledSuccess = compiledSuccess && validator.Success;

                        if (!compiledSuccess)
                        {
                            errorMessage = validator.Message;
                            break;
                        }
                    }

                    if (!compiledSuccess)
                    {
                        var scriptHelper3 = new ScriptHelper("ErrorAlert", "alertDiv", errorMessage + "Please try again without that image.");
                        Page.RegisterStartupScript(scriptHelper3.ScriptName, scriptHelper3.GetFatalScript());
                        return;
                    }

                    var scriptHelper2 = new ScriptHelper("SuccessAlert", "alertDiv", "You have successfully saved the image");
                    Page.RegisterStartupScript(scriptHelper2.ScriptName, scriptHelper2.GetSuccessScript());

                    uow.Commit();
                }
        }
Пример #5
0
        public void lnkAddMyShow_Click(object sender, EventArgs e)
        {
            var showService = new ShowService(Ioc.GetInstance<IShowRepository>());
            var myShowService = new MyShowService(Ioc.GetInstance<IMyShowRepository>());

            Guid userId = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
            var showId = new Guid(hdnShowId.Value);

            var show = showService.GetShow(showId);
            var myShow = myShowService.GetMyShow(showId, userId);

            if (myShow != null)
            {
                //phAlreadyAdded.Visible = true;
                return;
            }

            var newMyShow = new MyShow
            {
                CreatedDate = DateTime.Now,
                MyShowId = Guid.NewGuid(),
                ShowId = showId,
                UserId = userId
            };

            bool success = false;

            myShowService.SaveCommit(newMyShow, out success);

            if (success)
            {
                BindWithShowId(showId);
            }
            else
            {
                var scriptHelper = new ScriptHelper("ErrorAlert", "alertDiv", "There was a problem adding this show. If this happens again, then please contact the administrator.");
                Page.RegisterStartupScript(scriptHelper.ScriptName, scriptHelper.GetFatalScript());
            }
        }
Пример #6
0
 private void ShowNotSelectedMessage()
 {
     var scriptHelper = new ScriptHelper("ErrorAlert", "alertDiv", "To add pictures please click a year and then choose a show.");
     Page.RegisterStartupScript(scriptHelper.ScriptName, scriptHelper.GetFatalScript());
 }
Пример #7
0
        public void btnSubmitShowNotes_Click(object sender, EventArgs e)
        {
            ResetPanels();

            if (string.IsNullOrEmpty(hdnMyShowId.Value))
            {
                var scriptHelper3 = new ScriptHelper("ErrorAlert", "alertDiv", "There was an error saving your review.");
                Page.RegisterStartupScript(scriptHelper3.ScriptName, scriptHelper3.GetFatalScript());
                return;
            }

            var myShowService = new MyShowService(Ioc.GetInstance<IMyShowRepository>());

            var myShowId = new Guid(hdnMyShowId.Value);

            var myShow = myShowService.GetMyShow(myShowId);

            using (IUnitOfWork uow = UnitOfWork.Begin())
            {
                if (txtFree.Text.Length > 3000)
                {
                    var scriptHelper2 = new ScriptHelper("ErrorAlert", "alertDiv", "Your review was too long. Please keep it under 3000 characters.");
                    Page.RegisterStartupScript(scriptHelper2.ScriptName, scriptHelper2.GetFatalScript());
                    return;
                    }

                myShow.Notes = txtFree.Text;
                myShow.NotesUpdatedDate = DateTime.Now;

                uow.Commit();

                var scriptHelper = new ScriptHelper("SuccessAlert", "alertDiv", "Congratulations you have successfully saved a review for this show.");
                Page.RegisterStartupScript(scriptHelper.ScriptName, scriptHelper.GetSuccessScript());
            }

            ShowId = new Guid(hdnShowId.Value);
        }