Exemplo n.º 1
0
        // Lists Jobs with a given field matching a given value
        public IActionResult Cosmetics(CosmeticFieldType column, string value)
        {
            SearchCosmeticsViewModel searchVM = new SearchCosmeticsViewModel();

            searchVM.Cosmetics = context.FindByColumnAndValue(column, value);
            searchVM.Title     = "Cosmetics with " + column + ": " + value;

            return(View(searchVM));
        }
Exemplo n.º 2
0
        public IActionResult Values(CosmeticFieldType column)
        {
            if (column.Equals(CosmeticFieldType.All))
            {
                SearchCosmeticsViewModel searchVM = new SearchCosmeticsViewModel();
                searchVM.Cosmetics = context.Cosmetics.ToList();
                searchVM.Title     = "All Cosmetics";
                return(View("Cosmetics", searchVM));
            }
            else
            {
                CosmeticListViewModel listVM = new CosmeticListViewModel();

                IEnumerable <CosmeticField> fields;
                // List<CosmeticField> fields;

                switch (column)
                {
                case CosmeticFieldType.Finish:
                    fields = context.Finishs.ToList().Cast <CosmeticField>();
                    break;

                case CosmeticFieldType.Formulation:
                    fields = context.Formulations.ToList().Cast <CosmeticField>();
                    break;

                case CosmeticFieldType.Rating:
                    fields = context.Ratings.ToList().Cast <CosmeticField>();
                    break;

                case CosmeticFieldType.SkinType:
                    fields = context.SkinTypes.ToList().Cast <CosmeticField>();
                    break;

                case CosmeticFieldType.Color:
                default:
                    fields = context.Colors.ToList().Cast <CosmeticField>();
                    break;
                }

                listVM.Fields = fields;
                listVM.Title  = "All " + column + " Values";
                listVM.Column = column;

                return(View(listVM));
            }
        }
Exemplo n.º 3
0
        /**
         * Returns results of search the jobs data by key/value, using
         * inclusion of the search term.
         */
        public List <Cosmetic> FindByColumnAndValue(CosmeticFieldType column, string value)
        {
            IList <Cosmetic> cosmetics = Cosmetics
                                         .Include(f => f.Finish)
                                         .Include(c => c.Color)
                                         .Include(c => c.Formulation)
                                         .Include(r => r.Rating)
                                         .Include(s => s.SkinType)
                                         .ToList();


            var results = from j in cosmetics
                          where GetFieldByType(j, column).Contains(value)
                          select j;

            return(results.ToList());
        }
Exemplo n.º 4
0
        /**
         * Returns the JobField of the given type from the Job object,
         * for all types other than JobFieldType.All. In this case,
         * null is returned.
         */
        public static CosmeticField GetFieldByType(Cosmetic cosmetic, CosmeticFieldType type)
        {
            switch (type)
            {
            case CosmeticFieldType.Color:
                return(cosmetic.Color);

            case CosmeticFieldType.Finish:
                return(cosmetic.Finish);

            case CosmeticFieldType.Formulation:
                return(cosmetic.Formulation);

            case CosmeticFieldType.Rating:
                return(cosmetic.Rating);

            case CosmeticFieldType.SkinType:
                return(cosmetic.SkinType);
            }

            throw new ArgumentException("Cannot get field of type: " + type);
        }