Exemplo n.º 1
0
 public Product(int id, string name, string manufacturer, Category?category = null)
 {
     Id           = id;
     Name         = name;
     Manufacturer = manufacturer;
     Category     = category;
 }
Exemplo n.º 2
0
        private void OutputStreamsDocument(XDocument doc, Category?category = null, string dataItemId = null, string dataItemName = null, string dataItemType = null, string dataItemSubType = null, string filter = null)
        {
            var filters = new List <Func <IEnumerable <XElement>, IEnumerable <XElement> > >();

            if (category != null)
            {
                filters.Add(FilterByCategory(category.Value));
            }
            if (!string.IsNullOrWhiteSpace(dataItemId))
            {
                filters.Add(FilterByDataItemId(dataItemId));
            }
            if (!string.IsNullOrWhiteSpace(dataItemName))
            {
                filters.Add(FilterByDataItemName(dataItemName));
            }
            if (!string.IsNullOrWhiteSpace(dataItemType))
            {
                filters.Add(FilterByDataItemType(dataItemType));
            }
            if (!string.IsNullOrWhiteSpace(dataItemSubType))
            {
                filters.Add(FilterByDataItemSubType(dataItemSubType));
            }
            if (!string.IsNullOrWhiteSpace(filter))
            {
                filters.Add(FilterByGeneric(filter));
            }

            ProcessDoc(doc, filters.ToArray());
        }
Exemplo n.º 3
0
        private void ReplaceCategory(Category?newCategory, Func <Category?, bool> predicate)
        {
            foreach (var payee in Payees)
            {
                if (predicate(payee.DefaultCategory))
                {
                    payee.DefaultCategory = newCategory;
                }
            }

            foreach (var scheduledTransactions in ScheduledTransactions)
            {
                if (predicate(scheduledTransactions.Category))
                {
                    scheduledTransactions.Category = newCategory;
                }
            }

            foreach (var transactions in Transactions)
            {
                if (predicate(transactions.Category))
                {
                    transactions.Category = newCategory;
                }
            }
        }
        public IActionResult Home(Category?categoryId, int?cuisineId, int page = 1)
        {
            const int pageSize     = 7;
            var       selectedList = new List <SelectListItem>();

            var cuisines = User.Identity.IsAuthenticated
                ? _databaseManager.GetUserCuisines(User.Identity.Name)
                : new List <Cuisine> {
                _databaseManager.GetCuisine(1)
            };

            foreach (var cuisine in cuisines)
            {
                selectedList.Add(new SelectListItem {
                    Text = cuisine.Name, Value = cuisine.Id.ToString()
                });
            }

            //ViewData["Cuisines"] = selectedList;

            var source = _databaseManager.GetRecipeByCategoryAndCuisine(categoryId, cuisineId, User.Identity.Name);
            var count  = source.Count;
            var items  = source.Skip((page - 1) * pageSize).Take(pageSize).ToList();

            var pageViewModel = new PageViewModel(count, page, pageSize);
            var viewModel     = new MainViewModel
            {
                PageViewModel = pageViewModel,
                Recipes       = items,
                UserCuisines  = selectedList
            };

            return(View("~/Features/MainPage/Views/Home.cshtml", viewModel));
        }
Exemplo n.º 5
0
        static void Process(Options options)
        {
            var moduleSystem = LoadModuleSystem(options);

            var map      = new WCMap(options.TargetDirectory);
            var rootName = "WPSC_GENERATED";

            map.FindCategory(rootName)?.Remove();

            Category?rootCached = null;

            Category root() => rootCached ?? (rootCached = map.CreateCategory(rootName));

            if (moduleSystem != null)
            {
                using var writer = new StringWriter();
                moduleSystem.IncludeModuleLibrary(writer);
                var moduleScript = root().CreateScript("Module System");
                moduleScript.Source = writer.ToString();
            }

            var files = Directory
                        .GetFiles(options.SourceDirectory, "*.lua", SearchOption.AllDirectories)
                        .Where(f => !options.Excludes.Contains(Path.GetRelativePath(options.SourceDirectory, f)));

            Category?modules = null;

            ProcessDir(options, options.SourceDirectory, moduleSystem, () => modules ?? (modules = root().CreateCategory("Modules")));

            map.Save(options.TargetDirectory);
        }
Exemplo n.º 6
0
 public void SetCategoryForProduct(Product prodcut, Category?category)
 {
     if (category == null)
     {
         throw new ArgumentNullException($"Arguemnt {nameof(category)} is null");
     }
 }
        public IEnumerable <IPicture> GetRandomImages(int imageCount = 30, Category?category = null)
        {
            SetProtocol();

            var rc = CreateServiceClient();

            var rq = new RestRequest("photos/random", Method.GET);

            rq.AddQueryParameter("featured", "1");
            if (category.HasValue)
            {
                rq.AddQueryParameter("query", category.Value.ToString());
            }
            rq.AddQueryParameter("client_id", _appSecret);
            rq.AddQueryParameter("count", imageCount.ToString());


            var response = rc.Execute(rq);

            if (response.ErrorException != null)
            {
                throw response.ErrorException;
            }

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new Exception($"An error occured in unsplash service: {response.Content}");
            }

            var obj = JsonConvert.DeserializeObject <IEnumerable <UnSplashResponse> >(response.Content);

            return(obj.Select(x => new UnSplashPicture(x.links.download, x.links.html, x.user.name)).ToList());
        }
Exemplo n.º 8
0
        public static Uri GetUri(int width, int height, bool gray = false, Category? category = null, int? number = null, string text = null)
        {
            StringBuilder uri = new StringBuilder(RandomImage.BaseUri);

            if (!category.HasValue)
                category = (Category)Enum.GetValues(typeof(Category)).Random();

            if (gray)
                uri.Append("g/");

            uri.AppendFormat("{0}/{1}/", width, height);

            if (category.HasValue)
            {
                uri.AppendFormat("{0}/", category.ToString().ToLower());

                if (number.HasValue)
                    uri.AppendFormat("{0}/", number.Value);

                if (!text.IsNullOrEmpty())
                    uri.Append(text);
            }

            return new Uri(uri.ToString(), UriKind.Absolute);
        }
Exemplo n.º 9
0
        public RecurringPayment(DateTime startDate,
                                decimal amount,
                                PaymentType type,
                                PaymentRecurrence recurrence,
                                Account chargedAccount,
                                string note                    = "",
                                DateTime?endDate               = null,
                                Account?targetAccount          = null,
                                Category?category              = null,
                                DateTime?lastRecurrenceCreated = null)
        {
            if (!IsEndless && endDate != null && endDate < DateTime.Today)
            {
                throw new InvalidEndDateException();
            }

            ChargedAccount = chargedAccount ?? throw new ArgumentNullException(nameof(chargedAccount));
            StartDate      = startDate;
            EndDate        = endDate;
            Amount         = amount;
            Type           = type;
            Recurrence     = recurrence;
            Note           = note;
            Category       = category;
            TargetAccount  = targetAccount;
            IsEndless      = endDate == null;

            RelatedPayments = new List <Payment>();

            LastRecurrenceCreated = lastRecurrenceCreated ?? DateTime.Now;
            ModificationDate      = DateTime.Now;
            CreationTime          = DateTime.Now;
        }
Exemplo n.º 10
0
 public QueryArgument(QueryArgument right)
 {
     this.State    = right.State;
     this.Keyword  = right.Keyword;
     this.Category = right.Category;
     this.Creater  = right.Creater;
 }
Exemplo n.º 11
0
 public ProjectsQuery(int offset,
                      int count,
                      bool?isPrivate,
                      bool onlyScored,
                      string searchString,
                      Stage?stage,
                      string countryCode,
                      Category?category,
                      int?minimumScore,
                      int?maximumScore,
                      ProjectsOrderBy?orderBy,
                      SortDirection?direction,
                      IReadOnlyCollection <ScoringStatus> scoringStatuses,
                      IReadOnlyCollection <long> projectIds)
 {
     Offset          = offset;
     Count           = count;
     SearchString    = searchString;
     Stage           = stage;
     CountryCode     = countryCode;
     Category        = category;
     MinimumScore    = minimumScore;
     MaximumScore    = maximumScore;
     OrderBy         = orderBy;
     Direction       = direction;
     OnlyScored      = onlyScored;
     IsPrivate       = isPrivate;
     ScoringStatuses = scoringStatuses;
     ProjectIds      = projectIds;
 }
 public IActionResult GetMaterials(Category?category)
 {
     if (category != null && ((int)category >= 1 && (int)category <= 3))
     {
         return(Ok(_context.Materials.Include(p => p.Versions).Where(p => p.Category == category).ToList()));
     }
     return(Ok(_context.Materials.Include(p => p.Versions).ToList()));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Align with joined tables.
 /// </summary>
 public AnalyticalTeam With(
     IReadOnlyDictionary <int, Category> categories,
     IReadOnlyDictionary <int, Affiliation> affiliations)
 {
     _affiliation = affiliations[AffiliationId];
     _category    = categories[CategoryId];
     return(this);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Contrutor padrão com argumentos
 /// </summary>
 /// <param name="ProductId"> Seta o atributo _productId do objeto Product</param>
 /// <param name="description"> Seta o atributo _description do objeto Product</param>
 /// <param name="isFull"> Seta o atributo IsFull do objeto Product</param>
 /// <remarks>Danilo Aparecido</remarks>
 public Product(int?productId_, string description_, Category?category_, float?price_, bool isFull_)
 {
     this._productId   = productId_;
     this._description = description_;
     this._category    = category_;
     this._price       = price_;
     this.IsFull       = isFull_;
 }
        public async Task <IActionResult> ProductsForSale(int page = 1, Category?category = null)
        {
            var paginator = await this.productService.AllProductsForSale(page, category);

            paginator.ActionName = nameof(ProductsForSale);

            return(View(paginator));
        }
Exemplo n.º 16
0
 public int CompareTo(Category?other)
 {
     if (other == null)
     {
         return(-1);
     }
     return(String.Compare(Name, other.Name, StringComparison.Ordinal));
 }
Exemplo n.º 17
0
 public Product(int num, string name, string url, Category?category)
 {
     //productID = id;
     this._num      = num;
     this._name     = name;
     this._imageUrl = url;
     this._category = category;
 }
Exemplo n.º 18
0
        public void RefreshPictures(Category?category = null)
        {
            this._usedPictures = new List <IPicture>();

            this._unUsedPictures = new List <IPicture>();

            this._unUsedPictures = _srv.GetRandomImages(category: category ?? null).ToList();
        }
Exemplo n.º 19
0
        public static byte[] GetData(int width, int height, bool gray = false, Category? category = null, int? number = null, string text = null)
        {
            Uri uri = GetUri(width, height, gray, category, number, text);

            using (WebClient client = new WebClient())
            {
                return client.DownloadData(uri);
            }
        }
 public void Update(DateTime?date, Category?category, double?price, string?shopName, string?notes, byte[] version)
 {
     this.Price    = price ?? this.Price;
     this.Date     = date ?? this.Date;
     this.Category = category ?? this.Category;
     this.ShopName = shopName ?? this.ShopName;
     this.Notes    = notes ?? this.Notes;
     this.Version  = version;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Gets products by an artist.
        /// </summary>
        /// <param name="artist">The artist.</param>
        /// <param name="category">The category.</param>
        /// <param name="orderBy">The field to sort the items by.</param>
        /// <param name="sortOrder">The sort order of the items to fetch.</param>
        /// <param name="startIndex">The zero-based start index to fetch items from (e.g. to get the second page of 10 items, pass in 10).</param>
        /// <param name="itemsPerPage">The number of items to fetch.</param>
        /// <returns>
        /// A ListResponse containing Products or an Error
        /// </returns>
        /// <exception cref="System.ArgumentNullException">artist;Artist cannot be null</exception>
        public Task <ListResponse <Product> > GetArtistProductsAsync(Artist artist, Category?category = null, OrderBy?orderBy = null, SortOrder?sortOrder = null, int startIndex = MusicClient.DefaultStartIndex, int itemsPerPage = MusicClient.DefaultItemsPerPage)
        {
            if (artist == null)
            {
                throw new ArgumentNullException("artist", "Artist cannot be null");
            }

            return(this.GetArtistProductsAsync(artist.Id, category, orderBy, sortOrder, startIndex, itemsPerPage));
        }
        public static Level ToLevel(this Category?category)
        {
            if (category.HasValue)
            {
                return(category.Value.ToLevel());
            }

            return(Level.Debug);
        }
Exemplo n.º 23
0
 public Task <IEnumerable <Article> > GetTopHeadlinesAsync(Country?country,
                                                           Category?category,
                                                           string sources,
                                                           string keyword,
                                                           int?pageSize,
                                                           int?page)
 {
     return(_newsService.GetTopHeadlinesAsync(country, category, sources, keyword, pageSize, page));
 }
Exemplo n.º 24
0
 public QueryArgument(State?state       = null,
                      string keyword    = null,
                      Category?category = null,
                      string creater    = null)
 {
     this.State    = state;
     this.Keyword  = keyword;
     this.Category = category;
     this.Creater  = creater;
 }
Exemplo n.º 25
0
        public static bool IsOfCategory(string name, Category?category)
        {
            if (category == null)
            {
                return(true);
            }
            var ext = Path.GetExtension(name);

            return(category.Value.FileExtensions.Contains(ext.ToUpperInvariant()));
        }
Exemplo n.º 26
0
        public async Task <IActionResult> GetMany(Category?category, IEnumerable <string> labels, decimal?lowerPRice, decimal?higherPrice, int skip, int top)
        {
            IEnumerable <Product> result = await productsProvider.GetMany(category, labels, lowerPRice, higherPrice, skip, top);

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(result));
        }
Exemplo n.º 27
0
        public IQueryable <Advertisement> GetAdvertisementsQuery(Category?category = null)
        {
            var query = db.Advertisements.GetAll().Where(a => a.Premoderated);

            if (category.HasValue)
            {
                query = query.Where(a => a.Category == category);
            }

            return(query);
        }
Exemplo n.º 28
0
        public void gatherCarData()
        {
            Console.WriteLine("Please select your car-type:\n1: Casual\n2: Sports");
            int     type    = Int32.Parse(Console.ReadLine());
            CarType?carType = null;

            switch (type)
            {
            case 1:
                carType = CarType.Casual; break;

            case 2:
                carType = CarType.Sportscar; break;
            }
            Console.WriteLine("Please select a category:\n1: Sedan\n2: Coupe\n3: SUV\n4: Mini-Van");
            int      category    = Int32.Parse(Console.ReadLine());
            Category?carCategory = null;

            switch (category)
            {
            case 1:
                carCategory = Category.Sedan; break;

            case 2:
                carCategory = Category.Coupe; break;

            case 3:
                carCategory = Category.SUV; break;

            case 4:
                carCategory = Category.MiniVan; break;
            }
            Console.WriteLine("Brand:");
            string brand = Console.ReadLine();

            Console.WriteLine("Name:");
            string name = Console.ReadLine();

            Console.WriteLine("Build year:");
            int year = Int32.Parse(Console.ReadLine());

            Console.WriteLine("Color:");
            string color = Console.ReadLine();

            switch ((CarType)carType)
            {
            case CarType.Casual:
                carList.Add(new CasualCar((CarType)carType, (Category)carCategory, brand, name, year, color)); break;

            case CarType.Sportscar:
                Console.WriteLine("test");
                carList.Add(new SportsCar((CarType)carType, (Category)carCategory, brand, name, year, color)); break;
            }
        }
Exemplo n.º 29
0
        public List <Todo> GetAll(Category?category = null)
        {
            if (category.HasValue)
            {
                return(Todos
                       .Where(x => x.Category == category.Value)
                       .ToList());
            }

            return(Todos);
        }
Exemplo n.º 30
0
 public bool Equals(Category?other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Name == other.Name && Description == other.Description && Id == other.Id);
 }