Esempio n. 1
0
        public ActionResult SearchMusic(string music = null, int page = 1)
        {
            if (String.IsNullOrWhiteSpace(music))
            {
                ViewBag.Error = "You must at least search for one note";
                return(View("Music"));
            }
            FoireMusesConnection           connection   = GetConnection();
            SearchResult <ScoreSearchItem> searchResult = null;

            try
            {
                searchResult = connection.SearchScore((page - 1) * PageSize, PageSize, new Dictionary <string, object>()
                {
                    { "music", music }
                }, new Result <SearchResult <ScoreSearchItem> >()).Wait();
            }
            catch (Exception e)
            {
                return(RedirectToAction("Problem", "Error", null));
            }
            var viewModel = new ListViewModel <ScoreSearchItem>()
            {
                CurrentPage  = page,
                SearchResult = searchResult
            };

            return(View("ListScoreSearch", viewModel));
        }
Esempio n. 2
0
        public ActionResult SearchScore(string title = null, string editor = null, string composer = null, string verses = null, int page = 1)
        {
            FoireMusesConnection connection = GetConnection();

            if (String.IsNullOrWhiteSpace(title) && String.IsNullOrWhiteSpace(editor) && String.IsNullOrWhiteSpace(composer) && String.IsNullOrWhiteSpace(verses))
            {
                ViewBag.Error = "You must specify at least one criteria before making a search";
                return(View("Score"));
            }
            SearchResult <ScoreSearchItem> searchResult = null;

            try
            {
                searchResult = connection.SearchScore((page - 1) * PageSize, PageSize, new Dictionary <string, object>()
                {
                    { "title", title }, { "editor", editor }, { "composer", composer }, { "verses", verses }
                }, new Result <SearchResult <ScoreSearchItem> >()).Wait();
            }
            catch (Exception e)
            {
                return(RedirectToAction("Problem", "Error", null));
            }
            var viewModel = new ListViewModel <ScoreSearchItem>()
            {
                CurrentPage  = page,
                SearchResult = searchResult
            };

            return(View("ListScoreSearch", viewModel));
        }
        //AJAX CALL
        public ActionResult AjaxSearchMaster(string wordsToSearch)
        {
            theLogger.Info(String.Format("method GetPlaysForSource, parameter wordsToSearch {0}", wordsToSearch));
            if (String.IsNullOrWhiteSpace(wordsToSearch))
            {
                theLogger.Error("Reason: wordsToSearch is null or white space");
                return(PartialView("AjaxSearchForMaster", new List <ScoreSearchItem>()));
            }
            FoireMusesConnection           connection         = GetConnection();
            SearchResult <ScoreSearchItem> searchResultMaster = null;

            try
            {
                searchResultMaster = connection.SearchScore(0, 20, new Dictionary <string, object>()
                {
                    { "isMaster", true }, { "titleWild", wordsToSearch }
                }, new Result <SearchResult <ScoreSearchItem> >()).Wait();
            }
            catch (Exception e)
            {
                theLogger.Error("Stacktrace:\n" + e.StackTrace);
                return(PartialView("AjaxSearchForMaster", new List <ScoreSearchItem>()));
            }
            if (searchResultMaster == null)
            {
                theLogger.Error("Reason: searchResultMaster is null");
                return(PartialView("AjaxSearchForMaster", new List <ScoreSearchItem>()));
            }
            return(PartialView("AjaxSearchForMaster", searchResultMaster.Rows));
        }
        //
        // GET: /Scores/Details
        public ActionResult Details(string scoreId)
        {
            if (String.IsNullOrWhiteSpace(scoreId))
            {
                return(RedirectToAction("Missing", "Error", null));
            }

            FoireMusesConnection connection = GetConnection();
            Score  score        = null;
            Score  genericScore = null;
            Source sTextuelle   = null;
            Source sMusicale    = null;
            Play   assPlay      = null;
            IList <ScoreSearchItem> otherTitlesScore = null;
            IEnumerable <string>    attachedFiles    = null;
            IEnumerable <string>    documents        = null;

            try
            {
                score = connection.GetScore(scoreId, new Result <Score>()).Wait();
                if (score == null)
                {
                    return(RedirectToAction("Missing", "Error", null));
                }
                if (score.TextualSource != null && !String.IsNullOrWhiteSpace(score.TextualSource.SourceId))
                {
                    sTextuelle = connection.GetSource(score.TextualSource.SourceId, new Result <Source>()).Wait();
                    if (sTextuelle == null)
                    {
                        return(RedirectToAction("Problem", "Error", null));
                    }
                    if (!String.IsNullOrWhiteSpace(score.TextualSource.PieceId))
                    {
                        assPlay = connection.GetPlay(score.TextualSource.PieceId, new Result <Play>()).Wait();
                        if (assPlay == null)
                        {
                            return(RedirectToAction("Problem", "Error", null));
                        }
                    }
                }
                if (score.MusicalSource != null && !String.IsNullOrWhiteSpace(score.MusicalSource.SourceId))
                {
                    sMusicale = connection.GetSource(score.MusicalSource.SourceId, new Result <Source>()).Wait();
                    if (sMusicale == null)
                    {
                        return(RedirectToAction("Problem", "Error", null));
                    }
                }
                if (score.HasAttachement)
                {
                    attachedFiles = score.GetAttachmentNames().Where(x => !x.StartsWith("$"));
                    documents     = score.GetAttachmentNames().Where(x => x.StartsWith("$"));
                }
                if (score.IsMaster)
                {
                    SearchResult <ScoreSearchItem> results = connection.SearchScore(0, 0, new Dictionary <string, object>()
                    {
                        { "masterId", score.Id }
                    }, new Result <SearchResult <ScoreSearchItem> >()).Wait();
                    if (results == null)
                    {
                        return(RedirectToAction("Problem", "Error", null));
                    }
                    otherTitlesScore = results.Rows;
                }
                else if (score.MasterId != null)
                {
                    genericScore = connection.GetScore(score.MasterId, new Result <Score>()).Wait();
                    if (genericScore == null)
                    {
                        return(RedirectToAction("Problem", "Error", null));
                    }
                    SearchResult <ScoreSearchItem> results = connection.SearchScore(0, 0, new Dictionary <string, object>()
                    {
                        { "masterId", score.MasterId }
                    }, new Result <SearchResult <ScoreSearchItem> >()).Wait();
                    if (results == null)
                    {
                        return(RedirectToAction("Problem", "Error", null));
                    }
                    otherTitlesScore = results.Rows;
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("Problem", "Error", null));
            }
            ViewBag.TextualSource    = sTextuelle;
            ViewBag.AssociatedPlay   = assPlay;
            ViewBag.MusicalSource    = sMusicale;
            ViewBag.AttachedFiles    = attachedFiles;
            ViewBag.Documents        = documents;
            ViewBag.OtherTitlesScore = otherTitlesScore;
            ViewBag.GenericScore     = genericScore;
            return(View(score));
        }