コード例 #1
0
        public ActionResult Index(string word)
        {
            var searchModel = new SearchModel(word);

            searchModel.Search();
            return(View(searchModel));
        }
コード例 #2
0
        public ActionResult SearchArtifact(SearchModel model)
        {
            if (!string.IsNullOrWhiteSpace(model.SearchData))
            {
                if (model.Search())
                {
                    if (model.Results != null && model.Results.Count == 1)
                    {
                        return(Redirect(model.Results[0].Uri));
                    }
                    else if (model.Results != null && model.Results.Count > 1)
                    {
                        model.ReturnUrl = Request.UrlReferrer.AbsoluteUri;
                        return(View("SearchResult", model));
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(model.ReturnUrl))
            {
                return(Redirect(model.ReturnUrl));
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #3
0
 public IEnumerable <Employee> Search([FromUri] SearchModel mod)
 {
     //SearchModel model = new SearchModel();
     //model.keyword = mod.keyword;
     //model.employeeDateOfBirthFrom = mod.employeeDateOfBirthFrom;
     //model.employeeDateOfBirthTo = mod.employeeDateOfBirthTo;
     //model.EmployeeJobTitles = mod.EmployeeJobTitles;
     return(mod.Search(mod.keyword, mod.employeeDateOfBirthFrom, mod.employeeDateOfBirthTo, mod.EmployeeJobTitles));
 }
コード例 #4
0
ファイル: SearchModelTests.cs プロジェクト: hipigod/Dynamo
        /// <summary>
        /// Helper method for custom node adding and removing
        /// </summary>
        public static void AssertAddAndRemoveCustomNode(SearchModel searchModel, string nodeName, string catName, string descr = "Bla",
                                                        string path = "Bla")
        {
            var dummyInfo = new CustomNodeInfo(Guid.NewGuid(), nodeName, catName, descr, path);

            searchModel.Add(dummyInfo);

            var res = searchModel.Search(nodeName).ToList();

            Assert.AreNotEqual(0, res.Count());
            Assert.AreEqual(res[0].Name, nodeName);
            Assert.IsTrue(searchModel.ContainsCategory(catName));

            searchModel.RemoveNodeAndEmptyParentCategory(nodeName);
            res = searchModel.Search(nodeName).ToList();

            Assert.AreEqual(0, res.Count());
            Assert.IsFalse(searchModel.ContainsCategory(catName));
        }
コード例 #5
0
        public async Task <IHttpActionResult> PostSearch(FilterPathsDTO fp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            //using (var dbcontext = unitOfWorkFactory.CreateUnitOfWork())
            //{
            //IEnumerable<ConnectionPathDTO> conPaths = await Task.Run(() => searchModel.Search(fp, dbcontext));
            IEnumerable <ConnectionPathDTO> conPaths = await Task.Run(() => searchModel.Search(fp, unitOfWorkFactory));

            return(Ok(conPaths));
            //}
        }
コード例 #6
0
        public ActionResult Search(SearchViewModel search)
        {
            if (search.SearchParameters.From == search.SearchParameters.To ||
                search.SearchParameters.From == search.SearchParameters.Middle ||
                search.SearchParameters.Middle == search.SearchParameters.To)
            {
                return(View("MyError", new ErrorViewModel()
                {
                    ErrorMessage = "Wybrane stacje mają być różne."
                }));
            }

            search.ConnectionPaths = searchModel.Search(search.SearchParameters, unitOfFactory);
            return(View(search));
        }
コード例 #7
0
        public void SearchTest_ResultsPerPage_InvalidInteger()
        {
            //Arrange
            int page           = 1;
            int resultsPerPage = 100;
            int sortID         = 1;
            int categoryID     = 1;
            int priceID        = 0;
            int humidorSizeID  = 0;
            int colorID        = 0;
            //Act
            var search = new SearchModel(page, resultsPerPage, sortID, categoryID, priceID, humidorSizeID, colorID);
            var result = search.Search();

            // Assert
            Assert.AreEqual(8, result.Paging.ResultsPerPage);
        }
コード例 #8
0
        public void SearchTest_CategoryID_InvalidInteger()
        {
            //Arrange
            int page           = 1;
            int resultsPerPage = 8;
            int sortID         = 1;
            int categoryID     = 9999;
            int priceID        = 0;
            int humidorSizeID  = 0;
            int colorID        = 0;
            //Act
            var search = new SearchModel(page, resultsPerPage, sortID, categoryID, priceID, humidorSizeID, colorID);
            var result = search.Search();

            // Assert
            Assert.AreEqual(1, result.Filters.CategoryFilters.Id);
        }
コード例 #9
0
        public void SearchTest_Defaults_Valid()
        {
            //Arrange
            var search = new SearchModel();
            //Act
            var result = search.Search();

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(SearchViewModel));
            Assert.IsTrue(result.Paging.NumberOfItems > 0);
            Assert.IsTrue(result.Paging.Page == 1);
            Assert.IsTrue(result.Filters.CategoryFilters.Id == 1);
            Assert.IsTrue(result.Filters.PriceFilters.Id == 0);
            Assert.IsTrue(result.Filters.HumidorSizeFilters.Id == 0);
            Assert.IsTrue(result.Sorting.Id == 1);
        }
コード例 #10
0
        public void SearchTest_SortID_Negative()
        {
            //Arrange
            int page           = 1;
            int resultsPerPage = 8;
            int sortID         = -1;
            int categoryID     = 1;
            int priceID        = 0;
            int humidorSizeID  = 0;
            int colorID        = 0;
            //Act
            var search = new SearchModel(page, resultsPerPage, sortID, categoryID, priceID, humidorSizeID, colorID);
            var result = search.Search();

            // Assert
            Assert.AreEqual(1, result.Sorting.Id);
        }
コード例 #11
0
        public void SearchTest_Page_TooHigh()
        {
            //Arrange
            int page           = 9999;
            int resultsPerPage = 8;
            int sortID         = 1;
            int categoryID     = 1;
            int priceID        = 0;
            int humidorSizeID  = 0;
            int colorID        = 0;
            //Act
            var search = new SearchModel(page, resultsPerPage, sortID, categoryID, priceID, humidorSizeID, colorID);
            var result = search.Search();

            // Assert
            Assert.IsTrue(result.Paging.NumberOfPages < page);
            Assert.IsTrue(result.Paging.NumberOfPages > 0);
        }
コード例 #12
0
        public void SearchTest_ColorID_Negative()
        {
            //Arrange
            int page           = 1;
            int resultsPerPage = 8;
            int sortID         = 1;
            int categoryID     = 1;
            int priceID        = 1;
            int humidorSizeID  = 0;
            int colorID        = -1;
            //Act
            var search = new SearchModel(page, resultsPerPage, sortID, categoryID, priceID, humidorSizeID, colorID);
            var result = search.Search();

            // Assert
            Assert.AreEqual(0, result.Filters.ColorFilters.Id);
            Assert.AreEqual("", result.Filters.ColorFilters.Name);
            Assert.AreEqual("", result.Filters.ColorFilters.EqualityValue);
        }
コード例 #13
0
        public ActionResult Index(SearchModel model, string search, string next, string prev)
        {
            if (!string.IsNullOrWhiteSpace(next))
            {
                model = Session["SearchModel"] as SearchModel;

                if (model.Data.HasMore.HasValue)
                {
                    if (model.Data.HasMore.Value)
                    {
                        if (model.Page <= 1)
                        {
                            model.Page = 1;
                        }
                        model.Page++;
                    }
                }
            }
            if (!string.IsNullOrWhiteSpace(prev))
            {
                model = Session["SearchModel"] as SearchModel;

                if (model.Page <= 1)
                {
                    model.Page = 1;
                }

                model.Page--;
            }
            if (!string.IsNullOrWhiteSpace(search))
            {
            }

            Validate(ref model);

            model.Search();

            Session["SearchModel"] = model;

            SetImages(model.Data);

            return(View(model));
        }
コード例 #14
0
        public ActionResult Index(int page = 1, int resultsPerPage = 8, int sortID = 1, int categoryID = 1, int priceID = 0, int humidorSizeID = 0, int colorID = 0)
        {
            SearchModel     searchModel;
            SearchViewModel model;

            ViewBag.ErrorMessage = "";

            try
            {
                searchModel = new SearchModel(page, resultsPerPage, sortID, categoryID, priceID, humidorSizeID, colorID);
                model       = searchModel.Search();
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                model = new SearchModel().Search();
            }

            return(View(model));
        }
コード例 #15
0
ファイル: SearchModelTests.cs プロジェクト: hipigod/Dynamo
        public void CanRefactorCustomNodeName()
        {
            var nodeName   = "TheNoodle";
            var catName    = "TheCat";
            var descr      = "TheCat";
            var path       = @"C:\turtle\graphics.dyn";
            var guid1      = Guid.NewGuid();
            var dummyInfo1 = new CustomNodeInfo(guid1, nodeName, catName, descr, path);

            search.Add(dummyInfo1);

            Assert.AreEqual(1, search.SearchDictionary.NumElements);

            var newNodeName = "TheTurtle";
            var newInfo     = new CustomNodeInfo(guid1, newNodeName, catName, descr, path);

            search.Refactor(newInfo);

            Assert.AreEqual(1, search.SearchDictionary.NumElements);

            // search for new name
            var results = search.Search(newNodeName).ToList();

            // results are correct
            Assert.AreEqual(1, results.Count());
            var res1 = results[0];

            Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res1);
            var node1 = res1 as CustomNodeSearchElement;

            Assert.AreEqual(node1.Guid, guid1);

            // search for old name
            var results1 = search.Search(nodeName);

            // results are correct
            Assert.AreEqual(0, results1.Count());
        }
コード例 #16
0
        public ActionResult EditDeck(DeckModel model, int id, string search, string next, string prev, string save)
        {
            SearchModel      searchModel      = model.SearchModel;
            DeckDetailsModel deckDetailsModel = model.DeckDetails;

            Validate(ref searchModel);
            Validate(ref deckDetailsModel);

            if (id > 0)
            {
                DeckDetailsModel deckDetails = Session["DeckDetailsModel"] as DeckDetailsModel;
                if (DeckDetailsModel.IsEmpty(deckDetails))
                {
                    var tuple = DataManager.LoadDeck(id);
                    var deck  = tuple.Item1;
                    var cards = tuple.Item2;

                    deckDetails = new DeckDetailsModel()
                    {
                        DeckName        = deck.DeckName,
                        DeckDescription = deck.DeckDescription,
                        CardItems       = cards.Select(x => new CardItem()
                        {
                            CardID = x.CardId, Quantity = x.CardQuantity, Name = x.CardName
                        }).ToList()
                    };

                    deckDetailsModel = deckDetails;
                }
            }
            else
            {
                deckDetailsModel.CardItems = Session["CardItems"] as List <CardItem>;
            }

            if (!string.IsNullOrWhiteSpace(next))
            {
                searchModel = Session["SearchModel"] as SearchModel;

                if (searchModel.Data.HasMore.HasValue)
                {
                    if (searchModel.Data.HasMore.Value)
                    {
                        if (searchModel.Page <= 1)
                        {
                            searchModel.Page = 1;
                        }
                        searchModel.Page++;
                    }
                }
            }
            if (!string.IsNullOrWhiteSpace(prev))
            {
                searchModel = Session["SearchModel"] as SearchModel;

                if (searchModel.Page <= 1)
                {
                    searchModel.Page = 1;
                }

                searchModel.Page--;
            }
            if (!string.IsNullOrWhiteSpace(search))
            {
            }
            if (!string.IsNullOrWhiteSpace(save))
            {
                deckDetailsModel.CardItems = Session["CardItems"] as List <CardItem>;

                if (id == 0)
                {
                    id = DataManager.CreateDeck(model.DeckDetails.DeckName, model.DeckDetails.DeckDescription, deckDetailsModel.CardItems);
                    ClearSession();
                    return(RedirectToAction("Edit", "Decks", id));
                }
                else if (id >= 0)
                {
                    DataManager.SaveDeck(id, model.DeckDetails.DeckName, model.DeckDetails.DeckDescription, deckDetailsModel.CardItems);
                    ClearSession();
                    return(RedirectToAction("Edit", "Decks", id));
                }
            }

            searchModel.Search();

            Session["SearchModel"]      = searchModel;
            Session["DeckDetailsModel"] = deckDetailsModel;
            Session["CardItems"]        = deckDetailsModel.CardItems;

            model.DeckDetails = deckDetailsModel;
            model.SearchModel = searchModel;

            SetImages(searchModel.Data);

            return(View("Edit", model));
        }