Пример #1
0
        protected override async Task OnInitializedAsync()
        {
            Category   = new CategoriesViewModel();
            Categories = await CategoryService.GetAsync();

            Category = Categories.Where(c => c.Id == Id).FirstOrDefault();
        }
Пример #2
0
        public ActionResult AddCategory()
        {
            CategoriesViewModel categoriesViewModel = new CategoriesViewModel();

            categoriesViewModel.CategorieName = "";
            return(View(categoriesViewModel));
        }
Пример #3
0
        public string AddorRemoveLinks(CategoriesViewModel categoriesViewModelObj)
        {
            try
            {
                OperationsStatusViewModel OperationsStatusViewModelObj = new OperationsStatusViewModel();
                categoriesViewModelObj.commonObj             = new LogDetailsViewModel();
                categoriesViewModelObj.commonObj.CreatedBy   = _commonBusiness.GetUA().UserName;
                categoriesViewModelObj.commonObj.CreatedDate = _commonBusiness.GetCurrentDateTime();
                //Deserialize the string to object
                List <ProductCategoryLinkViewModel> ProductList       = JsonConvert.DeserializeObject <List <ProductCategoryLinkViewModel> >(categoriesViewModelObj.TableDataAdd);
                List <ProductCategoryLinkViewModel> ProductListDelete = JsonConvert.DeserializeObject <List <ProductCategoryLinkViewModel> >(categoriesViewModelObj.TableDataDelete);
                //Adding Created date and Createdby
                foreach (var i in ProductList)
                {
                    i.commonObj = categoriesViewModelObj.commonObj;
                }

                OperationsStatusViewModelObj = Mapper.Map <OperationsStatus, OperationsStatusViewModel>(_productBusiness.AddOrRemoveProductCategoryLink((Mapper.Map <List <ProductCategoryLinkViewModel>, List <ProductCategoryLink> >(ProductList)), (Mapper.Map <List <ProductCategoryLinkViewModel>, List <ProductCategoryLink> >(ProductListDelete))));
                if (OperationsStatusViewModelObj.StatusCode == 0 || OperationsStatusViewModelObj.StatusCode == 2)
                {
                    return(JsonConvert.SerializeObject(new { Result = "ERROR", Records = OperationsStatusViewModelObj }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new { Result = "OK", Records = OperationsStatusViewModelObj }));
                }
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = ex.Message }));
            }
        }
Пример #4
0
        public string SaveOrUpdateCategory(CategoriesViewModel categoriesViewModelObj)
        {
            try
            {
                OperationsStatusViewModel OperationsStatusViewModelObj = new OperationsStatusViewModel();
                categoriesViewModelObj.commonObj = new LogDetailsViewModel();
                if (categoriesViewModelObj.ID == 0)
                {
                    categoriesViewModelObj.commonObj.CreatedBy   = _commonBusiness.GetUA().UserName;
                    categoriesViewModelObj.commonObj.CreatedDate = _commonBusiness.GetCurrentDateTime();

                    OperationsStatusViewModelObj = Mapper.Map <OperationsStatus, OperationsStatusViewModel>(_categoryBusiness.InsertCategory(Mapper.Map <CategoriesViewModel, Categories>(categoriesViewModelObj)));
                }
                else
                {
                    categoriesViewModelObj.commonObj.UpdatedBy   = _commonBusiness.GetUA().UserName;
                    categoriesViewModelObj.commonObj.UpdatedDate = _commonBusiness.GetCurrentDateTime();
                    categoriesViewModelObj.ImageID = null;
                    OperationsStatusViewModelObj   = Mapper.Map <OperationsStatus, OperationsStatusViewModel>(_categoryBusiness.UpdateCategory(Mapper.Map <CategoriesViewModel, Categories>(categoriesViewModelObj)));
                }

                if (OperationsStatusViewModelObj.StatusCode == 0 || OperationsStatusViewModelObj.StatusCode == 2)
                {
                    return(JsonConvert.SerializeObject(new { Result = "ERROR", Records = OperationsStatusViewModelObj }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new { Result = "OK", Records = OperationsStatusViewModelObj }));
                }
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = ex.Message }));
            }
        }
Пример #5
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     BindingContext      = new CategoriesViewModel();
     lvItems.ItemTapped -= CategoriesViewModel.LvItems_ItemTapped;
     lvItems.ItemTapped += CategoriesViewModel.LvItems_ItemTapped;
 }
        public void LoadCategories_calles_categoryRepository_GetAll2()
        {
            var unitOfWork         = Substitute.For <IUnitOfWork>();
            var categoryRepository = Substitute.For <ICategoryRepository>();

            unitOfWork.Categories.Returns(categoryRepository);
            categoryRepository.GetAll(asNoTracking: true)
            .Returns(ImmutableList.Create(
                         new Category {
                Id = 1
            },
                         new Category {
                Id = 2
            },
                         new Category {
                Id = 3
            }));
            var eventAggregator = Substitute.For <IEventAggregator>();

            var vm = new CategoriesViewModel(unitOfWork, eventAggregator);

            vm.LoadCategories();

            Assert.NotNull(vm.Categories);
            Assert.NotEmpty(vm.Categories);
            Assert.Equal(3, vm.Categories.Count());
            Assert.Equal(1, vm.Categories.First().Id);
        }
Пример #7
0
        public IActionResult Categories()
        {
            var model = new CategoriesViewModel();

            model.Categories = _categoryService.GetList();
            return(View(model));
        }
Пример #8
0
        public async Task <OperationResult> Update(CategoriesViewModel viewModel)
        {
            Category existingcategory = await categoriesRepository.GetByIdAsync(viewModel.Id);

            existingcategory.Update(viewModel.Title, viewModel.Title_BG, viewModel.Icon);
            return(await categoriesRepository.UpdateAsync(existingcategory));
        }
Пример #9
0
        public AddCategoryViewModel GetCategoryData(string categoryId)
        {
            var category    = this.context.Categories.FirstOrDefault(c => c.Id == categoryId);
            var allCategory = this.context.Categories
                              .Where(c => c.Id != categoryId)
                              .Select(c => new CategoryViewModel()
            {
                Name       = c.Name,
                Id         = c.Name,
                ParentId   = c.ParentCategoryId,
                ParentName = c.ParentCategory.Name,
            }).ToList();
            CategoriesViewModel categories = new CategoriesViewModel()
            {
                Categories = allCategory,
            };


            var model = new AddCategoryViewModel()
            {
                Name                     = category.Name,
                ParentCategories         = categories,
                SelectedParentCategoryId = category.ParentCategoryId,
            };

            return(model);
        }
        public IActionResult SubmitCategory(CategoryViewModel categoryViewModel)
        {
            var category            = Mapper.Map <Category>(categoryViewModel);
            var categoriesViewModel = new CategoriesViewModel();

            category.Name = category.Name.Trim();
            if (category.Name == "")
            {
                throw new Exception("Du skal navngive din kategori");
            }

            if (categoryViewModel.Id != Guid.Empty)
            {
                _categoryRepository.UpdateCategory(category, _userManager.GetUserId(HttpContext.User));
                categoriesViewModel.PageAction = Enums.CategoriesPageAction.EditedCategory;
            }
            else
            {
                _categoryRepository.AddCategory(category, _userManager.GetUserId(HttpContext.User));
                categoriesViewModel.PageAction = Enums.CategoriesPageAction.AddedCategory;
            }

            ViewData["Title"] = "Kategorier";

            return(RedirectToAction("Categories", "Home", categoriesViewModel));
        }
Пример #11
0
        public CategoriesPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new CategoriesViewModel();
            viewModel.LoadCategoriesCommand.Execute(null);
        }
Пример #12
0
 public ActionResult <object> Post([FromBody] CategoriesViewModel user)
 {
     if (user == null)
     {
         var toSerialize = new MessageHelpers <CategoriesViewModel>()
         {
             Status = 404,
             Data   = null
         };
         return(JsonConvert.SerializeObject(toSerialize));
     }
     else
     {
         try
         {
             var id          = _categoriesServiceAsync.Add(user);
             var toSerialize = new MessageHelpers <CategoriesViewModel>()
             {
                 Status = 200,
                 Data   = null
             };
             return(JsonConvert.SerializeObject(toSerialize));
         }
         catch
         {
             var toSerialize = new MessageHelpers <CategoriesViewModel>()
             {
                 Status = 502,
                 Data   = null
             };
             return(JsonConvert.SerializeObject(toSerialize));
         }
     }
 }
Пример #13
0
        public HttpResponseMessage GetCategories(HttpRequestMessage request)
        {
            var categories            = _service.GetAllCategories();
            CategoriesViewModel model = new CategoriesViewModel(categories);

            return(request.CreateResponse <GroupCategoryViewModel[]>(HttpStatusCode.OK, model.GroupCategories.ToArray()));
        }
        public IActionResult Categories(Enums.CategoriesPageAction pageAction)
        {
            var userId = _userManager.GetUserId(HttpContext.User);
            var model  = new CategoriesViewModel()
            {
                PageAction       = pageAction,
                CategoryList     = _categoryRepository.GetCategoriesByUserId(userId),
                ActiveGameExists = ActiveGameExists(),
                HasActiveGame    = HasActiveGame(userId)
            };

            var message = "";

            switch (model.PageAction)
            {
            case Enums.CategoriesPageAction.AddedCategory:
                message = "Kategori tilføjet";
                break;

            case Enums.CategoriesPageAction.EditedCategory:
                message = "Kategori redigeret";
                break;

            case Enums.CategoriesPageAction.DeletedCategory:
                message = "Kategori slettet";
                break;
            }
            ViewData["Message"] = message;
            ViewData["Title"]   = "Kategorier";

            return(PartialView(model));
        }
Пример #15
0
        // We want to dynamically generate the buttons and their text based on the number of "IDs" gathered in the View Model
        // Unfortunately, XAML doesn't support looping statements of any kind, so I had to move the parent XAML code into this code-behind class
        // This feels messy, but I'm sure there's a better way by creating a custom control?
        private Grid CreateGridOfButtons(CategoriesViewModel vmContext)
        {
            var tileGrid = new Grid
            {
                Padding           = ButtonGridPadding,
                VerticalOptions   = ButtonGridVertOptions,
                HorizontalOptions = ButtonGridHorzOptions,
                RowSpacing        = ButtonGridRowSpacing,
                ColumnSpacing     = ButtonGridColumnSpacing,
                RowDefinitions    = CreateRowDefinitions(vmContext),
                ColumnDefinitions = CreateColumnDefinitions(vmContext)
            };

            for (var i = 0; i < vmContext.GetIDsCount(); i++)
            {
                tileGrid.Children.Add(new ThemedPopupButton
                {
                    Text            = vmContext.GetChildIDText(i),
                    Command         = vmContext.AlertDataPopup(i),
                    BackgroundColor = ThemedNavigationButton.ButtonBackgroundColor,
                    TextColor       = ThemedNavigationButton.ButtonTextColor,
                    FontSize        = ThemedNavigationButton.ButtonFontSize,
                    FontAttributes  = ThemedNavigationButton.ButtonFontAttributes
                }, 0, i);
            }

            return(tileGrid);
        }
Пример #16
0
 public ActionResult Delete(CategoriesViewModel model)
 {
     if (ModelState.IsValid)
     {
         using (POSContext context = new POSContext())
         {
             bool isSave  = false;
             var  VOutlet = context.TOutlet.ToList();
             foreach (var item in VOutlet)
             {
                 Categories Kategori = context.TCategories.Where(m => m.Name == model.Name).FirstOrDefault();
                 context.TCategories.Remove(Kategori);
                 try
                 {
                     context.SaveChanges();
                     isSave = true;
                 }
                 catch (Exception)
                 {
                     isSave = false;
                 }
             }
             if (isSave == true)
             {
                 return(RedirectToAction("Index"));
             }
         }
     }
     return(PartialView("Delete", model));
 }
Пример #17
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                viewM = this.Main.DataContext as CategoriesViewModel;
                viewM.SelectedData = new Categories();
                InsertData view = new InsertData("AJOUT", viewM.SelectedData, viewM);
                view.ShowDialog();

                if (view.Msg == "OK")
                {
                    MessageBox.Show("Opération effectuée avec succès", "Categories", MessageBoxButton.OK, MessageBoxImage.Information);
                    viewM.Refresh();
                }
                else if (view.Msg == "Error")
                {
                    MessageBox.Show("   Echec Opération    ", "Categories ", MessageBoxButton.OK, MessageBoxImage.Warning);
                    viewM.Refresh();
                }
                else
                {
                    viewM.Refresh();
                }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Categories", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Пример #18
0
        public MainPage()
        {
            var categories = new CategoriesPage();

            categories.Icon  = "ic_toc.png";
            categories.Title = "Categories";
            var categoriesViewModel = new CategoriesViewModel();

            categories.ViewModel = categoriesViewModel;

            var shoppingCart = new ShoppingCart();

            shoppingCart.Icon  = "ic_shopping_cart.png";
            shoppingCart.Title = "Shopping List";
            var shoppingCartViewModel = new ShoppingCartViewModel();

            shoppingCart.ViewModel = shoppingCartViewModel;

            var mealPlanner = new MealPlanner();

            mealPlanner.Icon  = "ic_schedule.png";
            mealPlanner.Title = "Meal Planner";
            var mealPlannerViewModel = new MealPlannerViewModel();

            mealPlanner.ViewModel = mealPlannerViewModel;

            Children.Add(shoppingCart);
            Children.Add(categories);
            Children.Add(mealPlanner);

            Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSwipePagingEnabled(this, false);
        }
Пример #19
0
        // ListItems yang akan diambil ini disesuaikan dengan kategori ID
        public ActionResult UpdateItems(CategoriesViewModel models)
        {
            using (POSContext context = new POSContext())
            {
                int i = 0;
                //var userId = User.Identity.GetUserId<int>();
                //int OutletId = 0;

                foreach (var item in models.ItemID)
                {
                    Items data = context.TItems.Where(x => x.ID == item).FirstOrDefault();
                    if (data != null)
                    {
                        data.CategoryID = models.ID;
                    }
                    i++;
                }
                try
                {
                    context.SaveChanges();
                    return(RedirectToAction("Index"));;
                }
                catch (Exception) { throw; };
            }
        }
Пример #20
0
 public CategoriesPage()
 {
     Analytics.TrackEvent("Navigate to Categories");
     InitializeComponent();
     BindingContext          = viewModel = SimpleIoc.Default.GetInstance <CategoriesViewModel>();
     AddPhotoButton.Clicked += AddPhotoButton_Clicked;
 }
Пример #21
0
        public async Task <ActionResult <Categories> > UpdateCategory(int id, CategoriesViewModel categoriesViewModel)
        {
            if (id != categoriesViewModel.Id)
            {
                return(BadRequest(id));
            }

            var category = await _applicationContext.Categories.GetAsync(id);

            if (category is null)
            {
                return(NotFound());
            }

            // Update our entity model
            category.Update(categoriesViewModel.Category);

            // Stage our entity
            _applicationContext.Categories.Update(category);

            // Commit changes to Db
            await _applicationContext.CommitAsync();

            return(NoContent());
        }
Пример #22
0
        public ActionResult Categories()
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnStr"].ConnectionString);

            SqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = "Select * from Categories";

            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            CategoriesViewModel model = new CategoriesViewModel();

            model.CategoryList = new List <Category>();

            while (reader.Read())
            {
                Category category = new Category();
                category.Id          = reader.GetInt32(0);
                category.Name        = reader.GetString(1);
                category.Description = reader.GetString(2);

                model.CategoryList.Add(category);
            }

            reader.Close();
            conn.Close();

            reader.Dispose();
            cmd.Dispose();
            conn.Dispose();

            return(View(model));
        }
 private void ReconcileCategories(CategoriesViewModel categories)
 {
     Categories = categories != null && categories.CategoryListView.OfType <CategoryViewModel>().Any()
         ? string.Join(", ", Hospital.Categories)
         : string.Empty;
     RaisePropertyChanged(() => Hospital);
 }
Пример #24
0
        public ActionResult SaveCategories(Category category)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new CategoriesViewModel
                {
                    Category = category,
                    Types    = _context.CategoryTypes.ToList()
                };
                return(View("_Categories", viewModel));
            }

            var id = category.CategoryId;

            if (id == 0)
            {
                _context.Categories.Add(category);
            }
            else
            {
                _context.Entry(category).State = EntityState.Modified;
            }
            _context.SaveChanges();
            //return RedirectToAction("Categories");
            return(RedirectToAction("AddCategories"));
        }
Пример #25
0
        public IActionResult Index()
        {
            CategoriesViewModel model = new CategoriesViewModel();

            model.Categories = this.Entities.Categories.ToList();
            return(View(model));
        }
Пример #26
0
        public IResult Update(CategoriesViewModel instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException();
            }

            IResult result = new Result(false);

            try
            {
                var category = new CategoriesModel();
                category.CategoryID   = instance.CategoryID;
                category.CategoryName = instance.CategoryName;
                category.Description  = instance.Description;
                category.Picture      = instance.Picture;

                _repository.categories.Update(category);
                result.Success = true;
            }
            catch (Exception ex)
            {
                result.Exception = ex;
            }
            return(result);
        }
Пример #27
0
        public IActionResult StartGameRound(CategoriesViewModel categories)
        {
            if (categories.AllCategories.TrueForAll(a => !a.Chosen))
            {
                categories.ErrorMessage = "Wählen Sie mindestens eine Kategorie aus.";
                return(View("ChooseCategories", categories));
            }

            var categoryIds        = categories.AllCategories.Where(a => a.Chosen).Select(a => a.CategoryId);
            var questions          = _gameHelper.GetQuestions(categoryIds);
            var questionsViewModel = questions.Select(a => new QuestionViewModel
            {
                QuestionId = a.QuestionId,
                Question   = a.Question,
                Answers    = _gameHelper.GetAnswers(a.QuestionId).ToList(),
                PercentageOfCorrectlyAnswered = a.AnsweredCorrectlyPercentage
            });

            var gameRound = new GameRoundViewModel
            {
                Categories      = categories.AllCategories.Where(a => a.Chosen).ToList(),
                GameBegin       = DateTime.Now,
                Score           = 0,
                QuestionsToPlay = questionsViewModel.ToList()
            };

            _gameHelper.SetNextQuestion(gameRound);

            return(View("GameRound", gameRound));
        }
Пример #28
0
        public async Task <IActionResult> PutCategory(CategoriesViewModel viewModel)
        {
            var category = await UnitOfWork.CategoryRepository.GetById(viewModel.Id);

            category.UrlTitle = viewModel.Description;
            category.Title    = viewModel.Title;
            category.Id       = viewModel.Id;


            if (category.Id != viewModel.Id)
            {
                return(BadRequest());
            }
            await UnitOfWork.CategoryRepository.Update(category);

            //_context.Entry(person).State = EntityState.Modified;

            try
            {
                await UnitOfWork.SaveAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IsExists(category.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #29
0
        public CategoriesListWithIconsPage(string _DateTime)
        {
            InitializeComponent();

            BindingContext = new CategoriesViewModel(_DateTime);
            NavigationPage.SetHasBackButton(this, false);
        }
Пример #30
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Travellist  = (Travellist)e.Parameter;
            DataContext = new CategoriesViewModel(Travellist);
            cvm         = (CategoriesViewModel)DataContext;
            var aantalItems     = 0;
            var aantalItemsDone = 0;

            foreach (Category cat in cvm.Categories)
            {
                aantalItems += cat.Items.Count;
                foreach (Item i in cat.Items)
                {
                    if (i.DoneItem)
                    {
                        aantalItemsDone++;
                    }
                }
            }
            progressbar.Maximum = aantalItems;
            progressbar.Value   = aantalItemsDone;
            double percentageDone = 100;

            if (aantalItems != 0)
            {
                percentageDone = progressbar.Value / progressbar.Maximum * 100;
            }

            ItemsDone.Text = Math.Round(percentageDone).ToString() + "%";
        }
 public ActionResult Edit(CategoriesViewModel model)
 {
     if (this.ModelState.IsValid && model != null)
     {
         this.Edit<Category>(model);
         return this.RedirectToAction("Index");
     }
     return this.View(model);
 }
Пример #32
0
 public MainViewModel()
 {
     Categories = new CategoriesViewModel();
     Counters = new CountersViewModel(Categories);
 }