Exemplo n.º 1
0
 public ActionResult Edit(Site obj)
 {
     if (string.IsNullOrEmpty(obj.Name) || string.IsNullOrEmpty(obj.Url) || obj.CategoryId == Guid.Empty)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     else
     {
         Site model = SiteBLL.GetById(obj.Id);
         if (model == null)
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
         else
         {
             model.Name        = obj.Name;
             model.Url         = obj.Url;
             model.Description = obj.Description;
             model.KeyWord     = obj.KeyWord;
             if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
             {
                 model.Logo = SaveFileReturnPath(Request.Files[0]);
             }
             model.MenuId     = CategoryList.FirstOrDefault(o => o.Id == obj.CategoryId).MenuId;
             model.CategoryId = obj.CategoryId;
             model.Is_Home    = obj.Is_Home;
             model.Is_Bar     = obj.Is_Bar;
             model.ShowOrder  = obj.ShowOrder;
             SiteBLL.Update(model);
             CacheManager.Remove(Consts.SiteCacheKey);
             return(Json(true, JsonRequestBehavior.AllowGet));
         }
     }
 }
Exemplo n.º 2
0
 public int GetFirstOrDefaultCategoryId(CategoryList categoryList)
 {
     if (categoryList == null)
     {
         return(0);
     }
     return(categoryList.FirstOrDefault());
 }
Exemplo n.º 3
0
        public static Category GetCategory(CategoryList categoryId)
        {
            if (categoryId != null && categoryId.Any())
            {
                return(_categoryRepository.Service.Get(categoryId.FirstOrDefault()));
            }

            return(null);
        }
Exemplo n.º 4
0
        public static string GetDisplayName(CategoryList categoryId)
        {
            if (categoryId != null && categoryId.Any())
            {
                var catId = categoryId.FirstOrDefault();
                return(GetDisplayName(catId));
            }

            return(string.Empty);
        }
        public void DeleteCategory(CategoryEntity newEntity)
        {
            CategoryEntity oldEntity = CategoryList.FirstOrDefault <CategoryEntity>(p => p.CategoryId == newEntity.CategoryId);

            if (oldEntity != null)
            {
                CategoryList.Remove(oldEntity);
            }

            CategoryList = new List <CategoryEntity>(_categoryList);
        }
        public void EditCategory(object item)
        {
            if (CanEditCategory(null))
            {
                if (SelectedCategory != null)
                {
                    CategoryData categoryItem = new CategoryData()
                    {
                        ProductCategoryID = SelectedCategory.ProductCategoryID,
                        Name     = CategoryName,
                        IsActive = CategoryIsActive
                    };
                    ProductCategory updatedProductCategory = CategoriesClient.UpdateCategory(categoryItem);

                    CategoryData categoryInList = CategoryList.FirstOrDefault(cat => cat.ProductCategoryID == updatedProductCategory.ProductCategoryID);
                    categoryInList.Name     = updatedProductCategory.Name;
                    categoryInList.IsActive = updatedProductCategory.IsActive;
                }
                else
                {
                    try
                    {
                        CategoryData categoryItem = new CategoryData()
                        {
                            ProductCategoryID = 0,
                            Name     = CategoryName,
                            IsActive = CategoryIsActive
                        };
                        ProductCategory updatedProductCategory = CategoriesClient.UpdateCategory(categoryItem);

                        if (updatedProductCategory != null)
                        {
                            CategoryList.Add(new CategoryData()
                            {
                                ProductCategoryID = updatedProductCategory.ProductCategoryID,
                                Name         = updatedProductCategory.Name,
                                IsActive     = updatedProductCategory.IsActive,
                                ProductCount = updatedProductCategory.ProductCount
                            });
                        }
                        else
                        {
                            MessageBox.Show("Save failed.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 7
0
 public void Cancel()
 {
     Book.TENSACH = dataProvider.GetItem <SACH>(x => x.MASACH == Book.MASACH).TENSACH;
     Book.NAMXB   = dataProvider.GetItem <SACH>(x => x.MASACH == Book.MASACH).NAMXB;
     Book.ANHBIA  = dataProvider.GetItem <SACH>(x => x.MASACH == Book.MASACH).ANHBIA;
     Author       = AuthorList.FirstOrDefault(x => x.MATG == Book.MATG);
     Category     = CategoryList.FirstOrDefault(x => x.MATL == Book.MATL);
     Publisher    = PublisherList.FirstOrDefault(x => x.MANXB == Book.MANXB);
     if (string.IsNullOrEmpty(Book.ANHBIA) == true || File.Exists(Book.ANHBIA) == false)
     {
         Book.ANHBIA = @"/Resources/Images/Book/DefaultBook.jpg";
     }
 }
Exemplo n.º 8
0
        public async Task <IActionResult> OnGetAsync(string categoryName)
        {
            if (categoryName.Length > 0)
            {
                ProductList = await _catalogApi.GetProductsByCategory(categoryName);

                SelectedCategory = CategoryList.FirstOrDefault(c => c == categoryName);
            }
            else
            {
                ProductList = await _catalogApi.GetProducts();
            }

            return(Page());
        }
Exemplo n.º 9
0
 public ActionResult Add(Site obj)
 {
     if (string.IsNullOrEmpty(obj.Name) || string.IsNullOrEmpty(obj.Url) || (Request.Files.Count <= 0 || Request.Files[0].ContentLength <= 0) || obj.CategoryId == Guid.Empty)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     else
     {
         obj.Id     = Guid.NewGuid();
         obj.Logo   = SaveFileReturnPath(Request.Files[0]);
         obj.MenuId = CategoryList.FirstOrDefault(o => o.Id == obj.CategoryId).MenuId;
         SiteBLL.Create(obj);
         CacheManager.Remove(Consts.SiteCacheKey);
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
 }
        public void AddOrUpdateCategory(CategoryEntity newEntity)
        {
            CategoryEntity oldEntity = CategoryList.FirstOrDefault <CategoryEntity>(p => p.Description == newEntity.Description);

            if (oldEntity == null)
            {
                CategoryList.Insert(0, newEntity);
            }
            else
            {
                int index = CategoryList.IndexOf(oldEntity);
                CategoryList.Remove(oldEntity);
                CategoryList.Insert(index, newEntity);
            }

            CategoryList = new List <CategoryEntity>(_categoryList);
        }
Exemplo n.º 11
0
 public BookDetailViewModel(DataProvider dataProvider, IEventAggregator eventAggregator) : base(dataProvider, eventAggregator)
 {
     AuthorList    = dataProvider.AuthorList;
     CategoryList  = dataProvider.CategoryList;
     PublisherList = dataProvider.PublisherList;
     Book          = dataProvider.SelectedBook;
     PublishRange  = dataProvider.LibraryRules.KHOANGCACHXB ?? 0;
     eventAggregator.Subscribe(this);
     Author     = AuthorList.FirstOrDefault(x => x.MATG == Book.MATG);
     Category   = CategoryList.FirstOrDefault(x => x.MATL == Book.MATL);
     Publisher  = PublisherList.FirstOrDefault(x => x.MANXB == Book.MANXB);
     DetailList = dataProvider.GetBookDetailList(x => x.MASACH == Book.MASACH);
     if (string.IsNullOrEmpty(Book.ANHBIA) == true || File.Exists(Book.ANHBIA) == false)
     {
         Book.ANHBIA = @"/Resources/Images/Book/DefaultBook.jpg";
     }
 }
Exemplo n.º 12
0
        public async Task <IActionResult> OnGetAsync(int?categoryId)
        {
            CategoryList = await _productRepository.GetCategories();

            if (categoryId.HasValue)
            {
                ProductList = await _productRepository.GetProductByCategory(categoryId.Value);

                SelectedCategory = CategoryList.FirstOrDefault(c => c.Id == categoryId.Value)?.Name;
            }
            else
            {
                ProductList = await _productRepository.GetProducts();
            }

            return(Page());
        }
Exemplo n.º 13
0
        public ShoppingCartFormViewModel()
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                RefreshProducts(null);

                ShoppingCart = ShoppingCartClient.GetShoppingCartList();
                List <CategoryData> list = new List <CategoryData>();
                list.Add(new CategoryData()
                {
                    ProductCategoryID = 0, Name = "All Categories"
                });
                list.AddRange(CategoriesClient.GetCategoryList().Where(c => c.IsActive == true).OrderBy(c => c.Name).ToList());
                CategoryList     = list;
                SelectedCategory = CategoryList.FirstOrDefault(c => c.ProductCategoryID == 0);
            }
        }
Exemplo n.º 14
0
        public async override void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);
            CategoryList = await App.DbHelper.GetAllCategory();

            if (parameters.ContainsKey("piece"))
            {
                Product           = parameters["piece"] as Product;
                SelectedCategory  = CategoryList.FirstOrDefault(e => e.Id.Equals(Product.Category));
                ItemList          = new List <Item>(await App.DbHelper.GetAllItems(SelectedCategory.Id));
                Product.ItemsUsed = new ObservableCollection <ItemUsed>(await App.DbHelper.GetAllItemUsed(Product.Id));
                foreach (ItemUsed item in Product.ItemsUsed)
                {
                    Item temp = ItemList.FirstOrDefault(e => e.Name.Equals(item.Type));
                    item.ItemSelected = temp;
                }
            }
        }
        /// <summary>
        /// Add a new category
        /// </summary>
        private void AddCategory()
        {
            if (string.IsNullOrWhiteSpace(NewCategoryName))
            {
                FormError = "EmptyCategoryName";
                return;
            }
            if (CategoryList.FirstOrDefault(x => x == NewCategoryName) != null)
            {
                FormError = "CategoryExists";
                return;
            }

            databaseRepository.AddCategory(NewCategoryName);
            Messenger.Default.Send(new CategoryAddedMessage(this, NewCategoryName));
            CategoryList.Add(NewCategoryName);
            StopAddCategory();
        }
Exemplo n.º 16
0
        private void AddPhotoButton_Click(object sender, RoutedEventArgs e)
        {
            PhotoList = Helper.Connection.Photo.ToList();
            if (TitleTextBox.Text == "" || FullFileName == "")
            {
                MessageBox.Show("Должны быть заполнены все поля");
                return;
            }
            Photo photo = PhotoList.FirstOrDefault(p => p.Path == FullFileName);

            if (photo != null)
            {
                MessageBox.Show("Добавление данной фотографии невозможно, так как она уже есть в базе");
                return;
            }
            try
            {
                string categoryTitle = CategoryComboBox.SelectedItem as string;

                Photo newPhoto = new Photo()
                {
                    Title    = TitleTextBox.Text,
                    Author   = Helper.CurrentAuthor,
                    Path     = FullFileName,
                    Category = CategoryList.FirstOrDefault(c => c.Title == categoryTitle)
                };

                Helper.Connection.Photo.Add(newPhoto);
                Helper.Connection.SaveChanges();
                MessageBox.Show("Добавление прошло успешно");

                FullFileName      = "";
                TitleTextBox.Text = "";
                CategoryComboBox.SelectedIndex = 0;
                ImageCheckBox.IsChecked        = false;
            }
            catch
            {
                MessageBox.Show("Ошибка во время добавления картинки в базу данных");
            }
        }
Exemplo n.º 17
0
        private static void processCategory(string text)
        {
            if (_firstRowForProduct)
            {
                var categories = extractCsvList(text);

                //just in case it's totally empty/null
                if (_currentProduct.SelectedProductCategories == null)
                {
                    _currentProduct.SelectedProductCategories = new Collection <ProductCategory>();
                }

                categories.ForEach(curCat =>
                {
                    //need to lookup categories
                    var category = CategoryList.FirstOrDefault(c => c.Name == curCat);
                    if (category != null)
                    {
                        var existing = _currentProduct.SelectedProductCategories.FirstOrDefault(c => c.Code == category.Code);
                        if (existing == null)
                        {
                            var newCat = new ProductCategory {
                                Code = category.Code, AdCategoryFlg = false
                            };
                            _currentProduct.SelectedProductCategories.Add(newCat);
                        }
                        else
                        {
                            //s/b nothing to do?
                        }
                    }
                });

                //remove any categories from product that aren't on the sheet; get list of codes from the sheet
                var sheetCategoryList = categories.Join(CategoryList, cat => cat, lookup => lookup.Name, (cat, lookup) => lookup.Code);
                var toRemove          = _currentProduct.SelectedProductCategories.Where(c => !sheetCategoryList.Contains(c.Code)).ToList();
                toRemove.ForEach(r => _currentProduct.SelectedProductCategories.Remove(r));
            }
        }
Exemplo n.º 18
0
        public static BaiduCategoryEntity GetBaiduCategory(int categorySysNo)
        {
            BaiduCategoryEntity category = BaiduCategoryList.FirstOrDefault(p => p.CategorySysNo == categorySysNo);

            if (category == null)
            {
                CategoryEntity categoryEntity = CategoryList.FirstOrDefault(p => p.CategoryId == categorySysNo);

                if (categoryEntity == null)
                {
                    return(new BaiduCategoryEntity());
                }
                else
                {
                    category = new BaiduCategoryEntity()
                    {
                        CategoryName = categoryEntity.CategoryName
                    };
                }
            }

            return(category);
        }
        /// <summary>
        /// Commit the category edition
        /// </summary>
        private void ValidateCategoryEdition()
        {
            if (string.IsNullOrWhiteSpace(CategoryInEdition))
            {
                FormError = "EmptyCategoryName";
                return;
            }
            if (CategoryList.FirstOrDefault(x => x == CategoryInEdition) != null && CategoryInEdition != originalCategoryInEdition)
            {
                FormError = "CategoryExists";
                return;
            }

            var index = CategoryList.IndexOf(originalCategoryInEdition);

            CategoryList[index] = CategoryInEdition;
            databaseRepository.UpdateCategory(originalCategoryInEdition, CategoryInEdition);
            Messenger.Default.Send(new CategoryEditedMessage(this, originalCategoryInEdition, CategoryInEdition));
            if (SelectedCategory == originalCategoryInEdition)
            {
                SelectedCategory = CategoryInEdition;
            }
            CategoryEditionFormVisibility = false;
        }
Exemplo n.º 20
0
        public async override void OnNavigatedTo(HBNavigationEventArgs e)
        {
            IsLoading = true;

            try
            {
                var board = e.Parameter as Board;
                if (board == null || board == Board)
                {
                    return;
                }

                await Task.Delay(300);

                CurrentCategory = CategoryList.FirstOrDefault(o => o.id == board.category_id);
                Board           = board;
            }
            catch (Exception ex)
            { }
            finally
            {
                IsLoading = false;
            }
        }
Exemplo n.º 21
0
 private void CurrentContributionChanged()
 {
     if (CurrentContribution != null)
     {
         if (CategoryList != null)
         {
             Category = CategoryList.FirstOrDefault(x => x.Name == CurrentContribution.CategoryName);
         }
         TotalAmount = CurrentContribution.ToatalAmount.ToString();
         CreatedOn   = CurrentContribution.CreatedOn;
         ContributionReceiptNumber = currentContribution.ReceiptNo;
         using (var unitofWork = new UnitOfWork(new MahalluDBContext())) {
             ContributionDetailList = new ObservableCollection <ContributionDetail>(unitofWork.ContributionDetails.Find((x) => x.Contribution_Id == CurrentContribution.Id));
             if (ContributionDetailList != null && ContributionDetailList.Count > 0)
             {
                 CurrentContributionDetail = ContributionDetailList[0];
             }
             else
             {
                 ClearContributionsDetailsList();
             }
         }
         //SetGuardian();
         IsEnable         = false;
         IsEnableCategory = false;
         IsEnableDetail   = false;
     }
     else
     {
         IsEnable         = true;
         IsEnableDetail   = false;
         IsEnableCategory = true;
         ClearContribution();
         ClearContributionsDetailsList();
     }
 }
Exemplo n.º 22
0
        public void EditProduct(object item)
        {
            if (CanEditProduct(null))
            {
                if (SelectedProduct != null)
                {
                    ProductData productItem = new ProductData()
                    {
                        ProductID          = SelectedProduct.ProductID,
                        Name               = ProductName,
                        ProductNumber      = ProductNumber,
                        Color              = Color,
                        ListPrice          = ListPrice,
                        ProductDescription = ProductDescription,
                        Quantity           = Quantity,
                        CategoryID         = CategoryID,
                        IsActive           = ProductIsActive
                    };
                    Product updatedProduct = ProductsClient.UpdateProduct(productItem);

                    ProductData productInList = ProductList.First(p => p.ProductID == updatedProduct.ProductID);
                    productInList.Name               = updatedProduct.Name;
                    productInList.Color              = updatedProduct.Color;
                    productInList.ListPrice          = updatedProduct.ListPrice;
                    productInList.ProductNumber      = updatedProduct.ProductNumber;
                    productInList.ProductDescription = updatedProduct.ProductDescription;
                    productInList.Quantity           = updatedProduct.Quantity;
                    productInList.IsActive           = updatedProduct.IsActive;
                    productInList.SalesOrderCount    = updatedProduct.SalesOrderItems.Count;

                    productInList.CategoryID = (int)updatedProduct.ProductCategoryID;
                    CategoryData category = CategoryList.FirstOrDefault(c => c.ProductCategoryID == (int)updatedProduct.ProductCategoryID);
                    productInList.CategoryName     = (category != null) ? category.Name : String.Empty;
                    productInList.IsCategoryActive = (category != null) ? category.IsActive : false;
                }
                else
                {
                    try
                    {
                        ProductData productItem = new ProductData()
                        {
                            ProductID          = 0,
                            Name               = ProductName,
                            CategoryID         = CategoryID,
                            Color              = Color,
                            ListPrice          = ListPrice,
                            ProductDescription = ProductDescription,
                            ProductNumber      = ProductNumber,
                            Quantity           = Quantity,
                            IsActive           = ProductIsActive
                        };
                        Product updatedProduct = ProductsClient.UpdateProduct(productItem);

                        if (updatedProduct != null)
                        {
                            ProductList.Add(new ProductData()
                            {
                                ProductID          = updatedProduct.ProductID,
                                Name               = updatedProduct.Name,
                                CategoryID         = (int)updatedProduct.ProductCategoryID,
                                Color              = updatedProduct.Color,
                                ListPrice          = updatedProduct.ListPrice,
                                ProductDescription = updatedProduct.ProductDescription,
                                ProductNumber      = updatedProduct.ProductNumber,
                                Quantity           = updatedProduct.Quantity,
                                IsActive           = updatedProduct.IsActive,
                                SalesOrderCount    = 0
                            });
                        }
                        else
                        {
                            MessageBox.Show("Save failed.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 23
0
 private void SelectedComboBox()
 {
     CategoryItem = CategoryList.FirstOrDefault(v => v.Id == MemoItem.CategoryId);
 }
 /// <summary>
 /// Send a CategorySelectedMessage
 /// </summary>
 /// <param name="selectedCategory"></param>
 private void SelectCategory(string selectedCategory)
 {
     SelectedCategory = CategoryList.FirstOrDefault(x => x == selectedCategory);
     Messenger.Default.Send(new CategorySelectedMessage(this, SelectedCategory));
 }
Exemplo n.º 25
0
        private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
        {
            Item SelectedItem = CategoryList.FirstOrDefault(itm => itm.Name == ((TappedEventArgs)e).Parameter.ToString());

            if (SelectedItem != null)
            {
                switch (SelectedItem.Name)
                {
                case "Label":
                {
                    Navigation.PushAsync(new CustomLabelsPage());

                    break;
                }

                case "Entry":
                {
                    Navigation.PushAsync(new CustomEntryPage());

                    break;
                }

                case "Action Bar":
                {
                    Navigation.PushAsync(new CustomActionBarSample());

                    break;
                }

                case "Charts":
                {
                    Navigation.PushAsync(new SampleChartsPage());

                    break;
                }

                case "Map":
                {
                    Navigation.PushAsync(new GoogleMapSample());

                    break;
                }

                case "Mulilingual":
                {
                    Navigation.PushAsync(new SelectLanguage());

                    break;
                }

                case "CustomTabs":
                {
                    Navigation.PushAsync(new CustomTabsSample());

                    break;
                }

                case "CustomAccordianView":
                {
                    Navigation.PushAsync(new CustomAccordianViewSample());

                    break;
                }

                case "LoginSample":
                {
                    Navigation.PushAsync(new LoginSamples());

                    break;
                }

                case "GalleryView":
                {
                    Navigation.PushAsync(new CustomGalleryView());

                    break;
                }

                case "FloatingTabs":
                {
                    Navigation.PushAsync(new FloatingTabsSample());

                    break;
                }

                case "CustomWebView":
                {
                    Navigation.PushAsync(new CustomDocViewer());

                    break;
                }

                case "FloatingButton":
                {
                    Navigation.PushAsync(new FloatingAddButton());

                    break;
                }

                case "XLabs Charts":
                {
                    Navigation.PushAsync(new XLabsChartsSample());

                    break;
                }

                case "MultiImagePicker":
                {
                    Navigation.PushAsync(new MultipleImagePicker());

                    break;
                }

                case "Custom Image Loader":
                {
                    Navigation.PushAsync(new CustomLoaderSample());

                    break;
                }

                case "Custom GIF Loader":
                {
                    Navigation.PushAsync(new CustomGIFLoaderSample());

                    break;
                }


                default:
                    break;
                }
            }
        }