public ActionResult DeleteSubConfirmed(int id)
        {
            SubCategory1 subCategory = db.SubCategories1.Find(id);

            db.SubCategories1.Remove(subCategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult CreateSubCategory(SubCategory1 subCategory1)
 {
     if (ModelState.IsValid)
     {
         db.SubCategories1.Add(subCategory1);
         db.SaveChanges();
         return(RedirectToAction("SubCategories", new { id = subCategory1.MainCategoryId }));
     }
     return(View(subCategory1));
 }
 public ActionResult EditSubCategory(SubCategory1 subcategory1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subcategory1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("SubCategories", new { id = subcategory1.MainCategoryId }));
     }
     return(View(subcategory1));
 }
예제 #4
0
        public async void ChangeContent(SubCategory1 sub1)
        {
            this.DataContext        = null;
            ProductMenu.ItemsSource = null;
            _Title.Text             = sub1.Name;
            productsList            = await service.GetJsonList("products", sub1.MainCategoryId, sub1.Id);

            Update(productsList);
            _Header.Visibility = Visibility.Visible;
            _Header.Height     = 65;
        }
예제 #5
0
 public async void ChangeContent(SubCategory1 sub1)
 {
     contentframe.NavigationService.Navigate(content);
     content.ChangeContent(sub1);
     LeftImages.Visibility  = Visibility.Hidden;
     sliderframe.Visibility = Visibility.Hidden;
     sliderframe.Height     = 0;
     _ScrollViewer.ScrollToTop();
     _MenuScroll.ScrollToTop();
     LeftImages.Height  = 0;
     Filters.Visibility = Visibility.Visible;
 }
        // GET: Category/DeleteSubCategory/5
        public ActionResult DeleteSubCategory(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SubCategory1 subCategory = db.SubCategories1.Find(id);

            if (subCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(subCategory));
        }
예제 #7
0
        private void ExpanderMenu_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement fe   = e.OriginalSource as FrameworkElement;
            MainCategory     main = fe.DataContext as MainCategory;
            SubCategory1     sub1 = fe.DataContext as SubCategory1;
            SubCategory2     sub2 = fe.DataContext as SubCategory2;

            if (main != null)
            {
                mainWindow.ChangeContent(main);
            }
            else if (sub1 != null)
            {
                mainWindow.ChangeContent(sub1);
            }
            else if (sub2 != null)
            {
                mainWindow.ChangeContent(sub2);
            }
        }
예제 #8
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            int cnt = 0;

            ExpanderMenu1.IsExpanded = false;
            if (ListViewMenu1.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
            {
                foreach (var item in ListViewMenu1.Items)
                {
                    SubCategory1 mdl       = (SubCategory1)ListViewMenu1.Items[cnt];
                    ListBoxItem  container = ListViewMenu1.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
                    Expander     expander  = FindVisualChild <Expander>(container, "ExpanderMenu2");
                    if (expander != null)
                    {
                        expander.Visibility = mdl.SubCategory2List.Count == 0 ? Visibility.Collapsed : Visibility.Visible;
                    }
                    cnt++;
                }
            }
        }
예제 #9
0
        public async Task NavigateFromMenu(int id, SubCategory1 sub1)
        {
            id = sub1.Id + 150;
            if (!MenuPages.ContainsKey(id))
            {
                MenuPages.Add(id, new NavigationPage(new HomePage(sub1)));
            }

            var newPage = MenuPages[id];

            if (newPage != null && Detail != newPage)
            {
                Detail = newPage;

                if (Device.RuntimePlatform == Device.Android)
                {
                    await Task.Delay(100);
                }

                IsPresented = false;
            }
        }
예제 #10
0
        public SubCategory1 Create(string name, int categoryId)
        {
            using (DataModelEntities model = new DataModelEntities())
            {
                SubCategory1 retVal = null;

                if (!model.SubCategory1.Any(s => s.CategoryId.Equals(categoryId) && s.Name.Equals(name)))
                {
                    retVal = new SubCategory1
                    {
                        Name       = name,
                        CategoryId = categoryId
                    };

                    model.SubCategory1.AddObject(retVal);
                    model.SaveChanges();
                }

                return(model.SubCategory1
                       .Include(s => s.Category)
                       .FirstOrDefault(s => s.Id.Equals(retVal.Id)));
            }
        }