Esempio n. 1
0
        void SavePhotoClicked()
        {
            PhotoItemObject.PhotoLabel = PhotoLabel;
            PhotoLabel = null;
            if (NewCategory != null)
            {
                AllCategories.Add(new Category(NewCategory, true));
                PickerSource.Add(NewCategory);
                MapCategorySource.Add(NewCategory);
                SaveCategoriesToJson();
            }

            var selectedCategories = (from category in AllCategories
                                      where category.IsChecked
                                      select category.Name).ToList <string>();

            // apply categories to most recent picture
            PhotoItemObject.Categories = selectedCategories;

            SaveToJson();

            // reset category picker
            for (int i = 0; i < AllCategories.Count; i++)
            {
                AllCategories[i].IsChecked = false;
            }

            PreviewImage = null;
            IsPhotoSet   = false;
            OnPropertyChanged("IsPhotoSet");
            NewCategory = null;
            OnPropertyChanged("NewCategory");
        }
Esempio n. 2
0
        public IActionResult Categories()
        {
            AllCategories allCategories = new AllCategories();

            allCategories.Categories = dbContext.Categories.ToList();
            return(View(allCategories));
        }
Esempio n. 3
0
        // open category picker page
        async Task SwipedRightCategorize(object commandParameter)
        {
            // reset
            for (int i = 0; i < AllCategories.Count; i++)
            {
                AllCategories[i].IsChecked = false;
            }

            PhotoItemObject = (PhotoItem)commandParameter;
            for (int i = 0; i < AllCategories.Count; i++)
            {
                if (Array.IndexOf(PhotoItemObject.Categories.ToArray(), AllCategories[i].Name) != -1)
                {
                    AllCategories[i].IsChecked = true;
                }
            }

            // show popup page
            var page = new PopupListView();

            page.BindingContext = this;
            await PopupNavigation.Instance.PushAsync(page);

            if (NewCategory != null)
            {
                AllCategories.Add(new Category(NewCategory, true));
                PickerSource.Add(NewCategory);
                MapCategorySource.Add(NewCategory);
                NewCategory = null;
                OnPropertyChanged("NewCategory");
                SaveCategoriesToJson();
            }
        }
Esempio n. 4
0
        public IActionResult AllCategories()
        {
            AllCategories model = new AllCategories();

            model.Categories = categoryRepository.GetAll().OrderBy(c => c.Title);
            return(View(model));
        }
Esempio n. 5
0
 public ModelCategory Find(string sCode)
 {
     if (AllCategories == null)
     {
         return(null);
     }
     return(AllCategories.Find(m => string.Equals(sCode, m.Code)));
 }
Esempio n. 6
0
 public List <ModelCategory> FindAllByParentID(int nID)
 {
     if (AllCategories == null)
     {
         return(new List <ModelCategory>());
     }
     return(AllCategories.FindAll(m => m.ParentId == nID));
 }
Esempio n. 7
0
 public ModelCategory Find(int nID)
 {
     if (AllCategories == null)
     {
         return(null);
     }
     return(AllCategories.Find(m => m.Id == nID));
 }
Esempio n. 8
0
 public OrdersViewModel()
 {
     AllCategories = ComboBoxService.GetOptions(ComboBoxTargets.ProductCategories);
     AllCategories.Add(new NameID
     {
         Name = "All",
         ID   = -1
     });
     CurrentCategory = AllCategories.Last();
 }
Esempio n. 9
0
        public List <SelectListItem> GetCategoriesListItems()
        {
            var result =
                AllCategories.Select(c => new SelectListItem
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();

            return(result);
        }
Esempio n. 10
0
        internal void AddCategory(ModelCategory modelParentCategory, ModelCategory modelCategory)
        {
            AllCategories.Add(modelCategory);
            modelParentCategory.Childs.Add(modelCategory);
            modelCategory.Parent = modelParentCategory;
            DacFactory.Current.Category.AddCategory(modelCategory);

            if (OnCategoryAdded != null)
            {
                OnCategoryAdded(modelCategory);
            }
        }
 public void Search()
 {
     if (SearchText != String.Empty)
     {
         Categories = new ObservableCollection <Category>
                          (AllCategories.Where(x => x.Name != null && x.Name.ToLower().Contains(_searchText.ToLower()))
                          .ToList());
     }
     else
     {
         Categories = AllCategories;
     }
 }
Esempio n. 12
0
        private static List <string> takeCategories(StreamReader file)
        {
            string        categoryHeader = file.ReadLine()?.Substring(9) ?? "";
            List <string> result         = categoryHeader.Split(" ").ToList();

            foreach (string category in result)
            {
                if (AllCategories.Find(cat => cat == category) == null)
                {
                    AllCategories.Add(category);
                }
            }
            return(result);
        }
Esempio n. 13
0
        public object Get(AllCategories request)
        {
            List <Category> result = new List <Category>();

            using (TagsDBUser user = new TagsDBUser(request.Test))
            {
                var readIf = GetReadInterface(user, request);
                foreach (var categoryForLanguage in readIf.GetAllCategories())
                {
                    result.Add(CreateItemResponse <Category, String>(request, categoryForLanguage.Name, user));
                }
                return(CreateHttpResponse(request, CreateItemResponse <AllCategoriesResponse, List <Category> >(request, result, user)));
            }
        }
        /// <summary>
        /// 初始化
        /// </summary>
        private async void InitCategories()
        {
            var tasks = new[] { this._netWorkServices.GetAsync <PlayListCategory[]>("FindMusic", "GetPlayListCategories"),
                                this._netWorkServices.GetAsync <PlayListCategory[]>("FindMusic", "GetHotPlayListCategories") };
            await Task.WhenAll(tasks);

            if (tasks.All(x => x.Result.Successed))
            {
                await Task.WhenAll(AllCategories.AddRangeAsync(tasks[0].Result.Data), HotCategories.AddRangeAsync(tasks[1].Result.Data));
            }
            else
            {
                //todo 网络提示信息
            }
        }
Esempio n. 15
0
        public ActionResult GetCategories()
        {
            List <Category> categories = new List <Category>();

            using (var ef = new EfContext())
            {
                categories = ef.Categories.ToList();
            }
            AllCategories retVal = new AllCategories
            {
                Categories = categories,
                Role       = ""
            };

            return(Json(retVal, JsonRequestBehavior.AllowGet));
        }
Esempio n. 16
0
 public IActionResult AddCategoryProcess(AllCategories modelData)
 {
     if (ModelState.IsValid)
     {
         Category NewCategory = modelData.Category;
         dbContext.Add(NewCategory);
         dbContext.SaveChanges();
         return(RedirectToAction("Categories"));
     }
     else
     {
         AllCategories allCategories = new AllCategories();
         allCategories.Categories = dbContext.Categories.ToList();
         return(View("Products", allCategories));
     }
 }
        public IEnumerable <Category> OrderAllCategory(int id)
        {
            var             allCategories   = AllCategories.ToList();
            List <Category> orderCategories = new List <Category>();

            foreach (var categoryLevel1 in allCategories)
            {
                if ((categoryLevel1.NestingLevelId == null) && (categoryLevel1.Id != id))
                {
                    orderCategories.Add(categoryLevel1);
                    foreach (var categoryLevel2 in allCategories)
                    {
                        if ((categoryLevel2.NestingLevelId == categoryLevel1.Id) && (categoryLevel2.Id != id))
                        {
                            categoryLevel2.Name = "-" + categoryLevel2.Name;
                            orderCategories.Add(categoryLevel2);
                            foreach (var categoryLevel3 in allCategories)
                            {
                                if ((categoryLevel3.NestingLevelId == categoryLevel2.Id) && (categoryLevel3.Id != id))
                                {
                                    categoryLevel3.Name = "--" + categoryLevel3.Name;
                                    orderCategories.Add(categoryLevel3);
                                    foreach (var categoryLevel4 in allCategories)
                                    {
                                        if ((categoryLevel4.NestingLevelId == categoryLevel3.Id) && (categoryLevel4.Id != id))
                                        {
                                            categoryLevel4.Name = "---" + categoryLevel4.Name;
                                            orderCategories.Add(categoryLevel4);
                                            foreach (var categoryLevel5 in allCategories)
                                            {
                                                if ((categoryLevel5.NestingLevelId == categoryLevel4.Id) && (categoryLevel5.Id != id))
                                                {
                                                    categoryLevel5.Name = "----" + categoryLevel5.Name;
                                                    orderCategories.Add(categoryLevel5);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(orderCategories);
        }
Esempio n. 18
0
        internal List <ModelCategory> GetAllChildCategories(int nCategoryID)
        {
            List <ModelCategory> aryResult = new List <ModelCategory>();
            ModelCategory        category  = AllCategories.Find(m => m.Id == nCategoryID);

            if (category != null)
            {
                aryResult.Add(category);

                List <ModelCategory> childCategories = AllCategories.FindAll(m => m.ParentId == nCategoryID);
                foreach (ModelCategory childCategory in childCategories)
                {
                    List <ModelCategory> aryChildCategory = GetAllChildCategories(childCategory.Id);
                    aryResult.AddRange(aryChildCategory);
                }
            }
            return(aryResult);
        }
 public void AddCategory()
 {
     try
     {
         using (var ctx = new ServerContext())
         {
             this.CreatedCategory.name = this.CategoryName;
             ctx.Category.Add(this.CreatedCategory);
             ctx.SaveChanges();
         }
         AllCategories.Add(CreatedCategory);
         this.CreatedCategory = new Category();
     }
     catch (System.Data.DataException)
     {
         PopupService.PopupMessage(Application.Current.FindResource("CouldNotConnectToDatabase").ToString(), Application.Current.FindResource("Error").ToString());
     }
 }
Esempio n. 20
0
 private void InitData()
 {
     foreach (BuiltInCategory enumCat in Enum.GetValues(typeof(BuiltInCategory)))
     {
         try
         {
             FilteredElementCollector collector = new FilteredElementCollector(Rvt.Handler.Doc);
             ElementCollection        elemC     = new ElementCollection(collector.OfCategory(enumCat).ToList());
             Category category = Category.GetCategory(Rvt.Handler.Doc, enumCat);
             if (elemC != null && elemC.Count > 0 &&
                 category != null && category.CategoryType == CategoryType.Model)
             {
                 AllCategories.Add(new CategoryNode(category, elemC));
             }
         }
         catch { continue; }
     }
 }
Esempio n. 21
0
        public IActionResult OnGet(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            StockToProducts = _context.StockToProducts.ToList();
            Product         = _context.Products.FirstOrDefault(m => m.Product_ID == id);
            Categories      = _context.Categories.Select(n => new SelectListItem
            {
                Value = n.Cat_ID.ToString(),
                Text  = n.CategoryName
            }).ToList();
            AllCategories = _context.Categories.ToList();
            SelectedTag   = AllCategories.FirstOrDefault(c => c.Cat_ID == Product.Cat_ID).Cat_ID.ToString();
            StockItems    = _context.Stock.ToList();

            List <string> stc = new List <string>();
            List <string> ssq = new List <string>();

            for (int stp = 0; stp < StockToProducts.Count; stp++)
            {
                if (StockToProducts[stp].ProductId == Product.Product_ID)
                {
                    stc.Add(StockItems[stp].StockName);
                    string qty = StockToProducts.FirstOrDefault(s => s.Id == StockToProducts[stp].Id).QuantityUse.ToString();
                    ssq.Add(qty);
                }
            }

            StockItemChecked        = stc;
            SelectedStockQuantities = ssq;

            if (Product == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Esempio n. 22
0
        private static ObservableCollection <StatisticItem> GetSpreadingStatisticItems(
            Func <List <FinancialTransaction> > getTransactionListFunc)
        {
            List <FinancialTransaction> transactionList = getTransactionListFunc();

            List <StatisticItem> tempStatisticList = AllCategories.Select(category => new StatisticItem {
                Category = category.Name,
                Value    = transactionList
                           .Where(x => x.Category == category)
                           .Sum(x => x.Amount)
            }).ToList();

            RemoveNullList(tempStatisticList);

            tempStatisticList = tempStatisticList.OrderByDescending(x => x.Value).ToList();
            List <StatisticItem> statisticList = tempStatisticList.Take(6).ToList();

            AddOtherItem(tempStatisticList, statisticList);

            IncludeIncome(statisticList);

            return(new ObservableCollection <StatisticItem>(statisticList));
        }
Esempio n. 23
0
 public void GetCategories()
 {
     Categories     = new ObservableCollection <Category>(AllCategories.Where(allcategory => Affiliation.CategoriesUsingInThisAffiliationFK.Contains(allcategory.CategoryId)));
     BindingContext = this;
 }
 public static void AddNewCategory(Category category)
 {
     AllCategories.Add(category);
 }
Esempio n. 25
0
        public async Task <IActionResult> OnPostExport(int currentPage, int pageSize, string sortOrder, string searchString)
        {
            Products = await InitiateView(currentPage, pageSize, sortOrder, searchString);

            string   sWebRootFolder = _hostingEnvironment.WebRootPath;
            string   sFileName      = @"Product Data.xlsx";
            string   URL            = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName);
            FileInfo file           = new FileInfo(Path.Combine(sWebRootFolder, sFileName));
            var      memory         = new MemoryStream();

            using (var fs = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Create, FileAccess.Write))
            {
                ExcelPackage package = new ExcelPackage();
                package.Workbook.Worksheets.Add("Products");
                ExcelWorksheet productsSheet = package.Workbook.Worksheets["Products"];
                using (var range = productsSheet.Cells["A1:I1"])
                {
                    range.Style.Font.Bold        = true;
                    range.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                    range.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(23, 121, 186));
                    range.Style.Font.Color.SetColor(Color.White);
                }
                productsSheet.Cells[1, 1].Value = "Product Id";
                productsSheet.Cells[1, 2].Value = "Product Name";
                productsSheet.Cells[1, 3].Value = "Product Short Description";
                productsSheet.Cells[1, 4].Value = "Product Detailed Description";
                productsSheet.Cells[1, 5].Value = "Selling Price";
                productsSheet.Cells[1, 6].Value = "Cost Price";
                productsSheet.Cells[1, 7].Value = "Profit Margin";
                productsSheet.Cells[1, 8].Value = "Category";
                productsSheet.Cells[1, 9].Value = "Stock Used";
                for (int r = 0; r < Products.Count(); r++)
                {
                    productsSheet.Cells[r + 2, 1].Value = Products.ToList()[r].Product_ID;
                    productsSheet.Cells[r + 2, 2].Value = Products.ToList()[r].ProductName;
                    productsSheet.Cells[r + 2, 3].Value = Products.ToList()[r].ProductShortDescription;
                    productsSheet.Cells[r + 2, 4].Value = Products.ToList()[r].ProductDetailedDescription;
                    productsSheet.Cells[r + 2, 5].Value = Products.ToList()[r].SellingPrice;
                    productsSheet.Cells[r + 2, 6].Value = Products.ToList()[r].CostPrice;
                    productsSheet.Cells[r + 2, 7].Value = Products.ToList()[r].ProfitMargin;
                    productsSheet.Cells[r + 2, 8].Value = AllCategories.FirstOrDefault(c => c.Cat_ID == Products.ToList()[r].Cat_ID).CategoryName;
                    string stock = string.Empty;
                    StockToProducts = _context.StockToProducts.ToList();
                    foreach (var stp in StockToProducts.Where(s => s.ProductId == Products.ToList()[r].Product_ID))
                    {
                        if (stock == "")
                        {
                            stock += _context.Stock.FirstOrDefault(st => st.Id == stp.StockId).StockName;
                        }
                        else
                        {
                            stock += ", " + _context.Stock.FirstOrDefault(st => st.Id == stp.StockId).StockName;
                        }
                    }
                    productsSheet.Cells[r + 2, 9].Value = stock;  // List All stock for this product
                    productsSheet.Cells[1, 1, 1, 9].AutoFitColumns();
                }

                package.SaveAs(fs);
                package.Dispose();
            }
            using (var stream = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Open))
            {
                await stream.CopyToAsync(memory);
            }
            memory.Position           = 0;
            TempData["StatusMessage"] = "Products successfully exported to file " + sFileName + ".";
            return(File(memory, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", sFileName));
        }
Esempio n. 26
0
 public IEnumerable <Category> GetChildCategories(int parentId)
 {
     return(AllCategories.Where(x => x.Parent_Id == parentId));
 }
 public ProductFormViewModel()
 {
     Product         = StateService.CurrentProduct;
     AllCategories   = ComboBoxService.GetOptions(ComboBoxTargets.ProductCategories);
     CurrentCategory = AllCategories.FirstOrDefault(x => x.ID == Product.CategoryID);
 }
 private void SortCategoriesAlphabetically()
 {
     AllCategories = new ObservableCollection <Category>(AllCategories.OrderBy(cat => cat.FullName));
 }
Esempio n. 29
0
        // constructor
        public PhotoViewModel()
        {
            // path of the file in the phone that stores the photo objects
            JsonFilePath = Path.Combine(Environment.GetFolderPath(
                                            Environment.SpecialFolder.LocalApplicationData), "photos.json");

            CategoryFilePath = Path.Combine(Environment.GetFolderPath(
                                                Environment.SpecialFolder.LocalApplicationData), "categories.json");

            /*
             *
             * if (File.Exists(JsonFilePath))
             * {
             *  File.Delete(JsonFilePath);
             * }
             * if (File.Exists(CategoryFilePath))
             * {
             *  File.Delete(CategoryFilePath);
             * }
             * return;
             */


            try
            {
                if (!File.Exists(JsonFilePath))
                {
                    // first time setup
                    FileStream   stream = new FileStream(JsonFilePath, FileMode.Create);
                    StreamWriter writer = new StreamWriter(stream);
                    writer.WriteLine("[]");
                    writer.Close();
                }
                else
                {
                    // already have photo objects
                    FileStream   stream       = new FileStream(JsonFilePath, FileMode.Open);
                    StreamReader reader       = new StreamReader(stream);
                    string       fileContents = reader.ReadToEnd();
                    reader.Close();
                    AllPhotos   = JsonConvert.DeserializeObject <List <PhotoItem> >(fileContents);
                    PhotoSource = new ObservableCollection <PhotoItem>(AllPhotos);
                }
                // read categories file
                if (!File.Exists(CategoryFilePath))
                {
                    // first time setup
                    FileStream   stream = new FileStream(CategoryFilePath, FileMode.Create);
                    StreamWriter writer = new StreamWriter(stream);
                    writer.WriteLine("[]");
                    writer.Close();
                }
                else
                {
                    /*
                     * List<string> s = new List<string> { "Foo", "Bar"};
                     * FileStream ss = new FileStream(CategoryFilePath, FileMode.Create);
                     * StreamWriter writer = new StreamWriter(ss);
                     * writer.WriteLine(JsonConvert.SerializeObject(s));
                     * writer.Close();
                     */

                    // already have categories
                    FileStream   stream       = new FileStream(CategoryFilePath, FileMode.Open);
                    StreamReader reader       = new StreamReader(stream);
                    string       fileContents = reader.ReadToEnd();
                    Console.WriteLine("g" + fileContents);
                    reader.Close();

                    List <string> fileCategories = JsonConvert.DeserializeObject <List <string> >(fileContents);



                    var categoryObjects = from category in fileCategories
                                          select new Category(category);


                    foreach (string x in fileCategories)
                    {
                        MapCategorySource.Add(x);
                        PickerSource.Add(x);
                    }
                    PickerSource.Add("Location");
                    PickerSource.Add("Rating");
                    PickerSource.Add("Time");



                    foreach (var x in PickerSource)
                    {
                        Console.WriteLine(x);
                    }
                    AllCategories = new ObservableCollection <Category>(categoryObjects);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception " + ex.Message);
            }

            InitialCategorizeCommand = new Command(
                execute: async() =>
            {
                await InitialCategorize();
            },
                canExecute: () =>
            {
                return(true);
            });
            PrintCommand = new Command(
                execute: () =>
            {
                PrintJsonFile();
            },
                canExecute: () =>
            {
                return(true);
            });
            SaveLabelCommand = new Command(
                execute: (obj) =>
            {
                PhotoItem temp = (PhotoItem)obj;
            });
            PopupCommand = new Command(
                execute: async() =>
            {
                // show popup to categorize photo
                await PopupNavigation.Instance.PopAsync();

                if (NewCategory != null)
                {
                    AllCategories.Add(new Category(NewCategory, true));
                    PickerSource.Add(NewCategory);
                    MapCategorySource.Add(NewCategory);
                    NewCategory = null;
                    OnPropertyChanged("NewCategory");
                    SaveCategoriesToJson();
                }
                PhotoItemObject.Categories = (from category in AllCategories
                                              where category.IsChecked
                                              select category.Name).ToList();

                SaveToJson();
            },
                canExecute: () =>
            {
                return(true);
            });
            LoadPhotoCommand = new Command(
                execute: async() =>
            {
                var photo = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(
                    new Plugin.Media.Abstractions.PickMediaOptions
                {
                    CompressionQuality = 50,
                    PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Large
                });
                await SetNewPhoto(photo);
            },
                canExecute: () =>
            {
                return(true);
            });
            TakePhotoCommand = new Command(
                execute: async() =>
            {
                var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(
                    new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    SaveToAlbum = true
                });
                await SetNewPhoto(photo);
            },
                canExecute: () =>
            {
                return(true);
            });
            SavePhotoCommand = new Command(
                execute: () =>
            {
                SavePhotoClicked();
            },
                canExecute: () =>
            {
                return(true);
            });
            RatingCommand = new Command(
                execute: () =>
            {
                IsRating     = !IsRating;
                IsCategorize = false;
            },
                canExecute: () =>
            {
                return(true);
            });
            CategorizeCommand = new Command(
                execute: () =>
            {
                IsCategorize = !IsCategorize;
                IsRating     = false;
            },
                canExecute: () =>
            {
                return(true);
            });
            SwipeCommandLeft = new Command(
                execute: (obj) =>
            {
                if (isRating)
                {
                    SwipedLeftRating(obj);
                }
                else if (isCategorize)
                {
                    SwipedLeftCategorize(obj);
                }
            },
                canExecute: (obj) =>
            {
                return(true);
            });
            SwipeCommandRight = new Command(
                execute: (obj) =>
            {
                if (isRating)
                {
                    SwipedRightRating(obj);
                }
                else if (isCategorize)
                {
                    SwipedRightCategorize(obj);
                }
            },
                canExecute: (obj) =>
            {
                return(true);
            });
        }
Esempio n. 30
0
 public CategoryCached GetCategory(int id)
 {
     return(AllCategories.FirstOrDefault(x => x.Value.Id == id).Value);
 }