Exemple #1
0
 public UserModule(IRegionManager regionManager)
 {
     ListUserRolesCommand = new CategoryCommand<string>(Resources.UserRoleList, Resources.Users, OnListRoles) { Order = 50 };
     ListUsersCommand = new CategoryCommand<string>(Resources.UserList, Resources.Users, OnListUsers);
     NavigateLogoutCommand = new CategoryCommand<string>("Logout", Resources.Common, "images/bmp.png", OnNavigateUserLogout) { Order = 99 };
     _regionManager = regionManager;
 }
        public async Task CreateCategoryProvidesCategoryToStoreTest()
        {
            var expected = Model.Create <NewCategory>();

            var store = Substitute.For <ICategoryStore>();
            var cache = Substitute.For <ICategoryCache>();

            var sut = new CategoryCommand(store, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                await sut.CreateCategory(expected, tokenSource.Token).ConfigureAwait(false);

                await store.Received(1).StoreCategory(Arg.Any <Category>(), tokenSource.Token).ConfigureAwait(false);

                await store.Received().StoreCategory(
                    Arg.Is <Category>(x => x.Group == expected.Group),
                    tokenSource.Token).ConfigureAwait(false);

                await store.Received().StoreCategory(Arg.Is <Category>(x => x.Name == expected.Name), tokenSource.Token)
                .ConfigureAwait(false);

                await store.Received().StoreCategory(Arg.Is <Category>(x => x.LinkCount == 0), tokenSource.Token)
                .ConfigureAwait(false);

                await store.Received().StoreCategory(Arg.Is <Category>(x => x.Reviewed), tokenSource.Token)
                .ConfigureAwait(false);

                await store.Received().StoreCategory(Arg.Is <Category>(x => x.Visible), tokenSource.Token)
                .ConfigureAwait(false);

                cache.Received().RemoveCategories();
                cache.Received().RemoveCategory(expected.Group, expected.Name);
            }
        }
Exemple #3
0
        public IActionResult Post([FromBody] CategoryCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(
                           new ResultViewModel
                {
                    Success = false,
                    Message = "Erro ao cadastrar categoria",
                    Data = ModelState.GetErrors()
                }));
            }

            var category = _mapper.Map <Category>(command);

            _repository.Save(category);

            return(new OkObjectResult(
                       new ResultViewModel
            {
                Success = true,
                Message = "Categoria Cadastrada com sucesso",
                Data = _mapper.Map <CategoryCreateResult>(category)
            }));
        }
Exemple #4
0
        public IActionResult Put([FromBody] CategoryCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(
                           new ResultViewModel
                {
                    Success = false,
                    Message = "Erro ao cadastrar categoria",
                    Data = ModelState.GetErrors()
                }));
            }

            var category = _repository.GetById(command.Id);

            if (category == null)
            {
                return(new NotFoundObjectResult($"Categoria com o Id {command.Id} não encontrada!"));
            }

            category.Title = command.Title;
            _repository.Update(category);

            return(new OkObjectResult(
                       new ResultViewModel
            {
                Success = true,
                Message = "Categoria Cadastrada com sucesso",
                Data = _mapper.Map <CategoryCreateResult>(category)
            }));
        }
Exemple #5
0
 public CashModule(IRegionManager regionManager, CashView cashView)
 {
     _regionManager = regionManager;
     _cashView = cashView;
     NavigateCashViewCommand = new CategoryCommand<string>(Resources.Drawer, Resources.Common, "images/Xls.png", OnNavigateCashView, CanNavigateCashView) { Order = 70 };
     PermissionRegistry.RegisterPermission(PermissionNames.NavigateCashView, PermissionCategories.Navigation, Resources.CanNavigateCash);
     PermissionRegistry.RegisterPermission(PermissionNames.MakeCashTransaction, PermissionCategories.Cash, Resources.CanMakeCashTransaction);
 }
Exemple #6
0
 public SupplierModule(IRegionManager regionManager, SupplierSelectorView SupplierSelectorView)
 {
     _regionManager = regionManager;
     _SupplierSelectorView = SupplierSelectorView;
     ListSuppliersCommand = new CategoryCommand<string>(Resources.SupplierList, Resources.Products, OnSupplierListExecute) { Order = 40 };
     PermissionRegistry.RegisterPermission(PermissionNames.MakeAccountTransaction, PermissionCategories.Cash, Resources.CanMakeAccountTransaction);
     PermissionRegistry.RegisterPermission(PermissionNames.CreditOrDeptAccount, PermissionCategories.Cash, Resources.CanMakeCreditOrDeptTransaction);
 }
Exemple #7
0
 public CustomerModule(IRegionManager regionManager, CustomerSelectorView customerSelectorView)
 {
     _regionManager = regionManager;
     _customerSelectorView = customerSelectorView;
     ListCustomersCommand = new CategoryCommand<string>(Resources.CustomerList, Resources.Customers, OnCustomerListExecute) { Order = 40 };
     PermissionRegistry.RegisterPermission(PermissionNames.MakeAccountTransaction, PermissionCategories.Cash, Resources.CanMakeAccountTransaction);
     PermissionRegistry.RegisterPermission(PermissionNames.CreditOrDeptAccount, PermissionCategories.Cash, Resources.CanMakeCreditOrDeptTransaction);
 }
Exemple #8
0
 public TableModule(IRegionManager regionManager, TableSelectorView tableSelectorView)
 {
     _regionManager = regionManager;
     _tableSelectorView = tableSelectorView;
     ListTablesCommand = new CategoryCommand<string>(Resources.TableList, Resources.Tables, OnListTablesExecute) { Order = 30 };
     ListTableScreensCommand = new CategoryCommand<string>(Resources.TableViews, Resources.Tables, OnListTableScreensExecute);
     NavigateTablesCommand = new CategoryCommand<string>(Resources.Tables, Resources.Common, "images/Png.png", OnNavigateTables, CanNavigateTables);
 }
Exemple #9
0
 public CategoryTest(
     TestWebApplicationFactory factory,
     ITestOutputHelper output
     ) : base(factory, output)
 {
     Command = new CategoryCommand
     {
         Title = "Category"
     };
 }
        /// <summary>
        /// 编辑分类
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task <ActionResult> Edit(CategoryCommand dto)
        {
            var cat = await CategoryService.GetByIdAsync(dto.Id) ?? throw new NotFoundException("分类不存在!");

            cat.Name        = dto.Name;
            cat.Description = dto.Description;
            bool b = await CategoryService.SaveChangesAsync() > 0;

            return(ResultData(null, b, b ? "分类修改成功!" : "分类修改失败!"));
        }
Exemple #11
0
 public TableModule(IRegionManager regionManager, TableSelectorView tableSelectorView)
 {
     _regionManager     = regionManager;
     _tableSelectorView = tableSelectorView;
     ListTablesCommand  = new CategoryCommand <string>(Resources.TableList, Resources.Tables, OnListTablesExecute)
     {
         Order = 30
     };
     ListTableScreensCommand = new CategoryCommand <string>(Resources.TableViews, Resources.Tables, OnListTableScreensExecute);
     NavigateTablesCommand   = new CategoryCommand <string>(Resources.Tables, Resources.Common, "images/Png.png", OnNavigateTables, CanNavigateTables);
 }
        public void UpdateCategoryThrowsExceptionWithNullCategoryTest()
        {
            var store = Substitute.For <ICategoryStore>();
            var cache = Substitute.For <ICategoryCache>();

            var sut = new CategoryCommand(store, cache);

            Func <Task> action = async() =>
                                 await sut.UpdateCategory(null, CancellationToken.None).ConfigureAwait(false);

            action.Should().Throw <ArgumentNullException>();
        }
Exemple #13
0
 public UserModule(IRegionManager regionManager)
 {
     ListUserRolesCommand = new CategoryCommand <string>(Resources.UserRoleList, Resources.Users, OnListRoles)
     {
         Order = 50
     };
     ListUsersCommand      = new CategoryCommand <string>(Resources.UserList, Resources.Users, OnListUsers);
     NavigateLogoutCommand = new CategoryCommand <string>("Logout", Resources.Common, "images/bmp.png", OnNavigateUserLogout)
     {
         Order = 99
     };
     _regionManager = regionManager;
 }
Exemple #14
0
        public async Task <IActionResult> SaveCategory(CategoryCommand cmd)
        {
            var result = await Mediator.Send(cmd);

            if (result.Success)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest(result.HttpResponse));
            }
        }
Exemple #15
0
        public MenuModule()
        {
            ListDepartmentsCommand = new CategoryCommand<string>(Resources.Departments, Resources.Settings, OnListDepartments);
            ListMenuItemsCommand = new CategoryCommand<string>(Resources.ProductList, Resources.Products, OnListMenuItems);
            ListScreenMenusCommand = new CategoryCommand<string>(Resources.MenuList, Resources.Products, OnListScreenMenus);
            ListMenuItemPropertyGroupsCommand = new CategoryCommand<string>(Resources.ModifierGroups, Resources.Products, OnListMenuItemPropertyGroupsCommand);
            ListPricesCommand = new CategoryCommand<string>(Resources.BatchPriceList, Resources.Products, OnListPrices);
            ListTicketTagGroupsCommand = new CategoryCommand<string>(Resources.TicketTags, Resources.Settings, OnListTicketTags) { Order = 10 };
            ListMenuItemPriceDefinitionsCommand = new CategoryCommand<string>(Resources.PriceDefinitions, Resources.Products, OnListMenuItemPriceDefinitions);
            ListVatTemplatesCommand = new CategoryCommand<string>(Resources.VatTemplates, Resources.Products, OnListVatTemplates);
            ListTaxServiceTemplates = new CategoryCommand<string>(Resources.TaxServiceTemplates, Resources.Products, OnListTaxServiceTemplates);

            PermissionRegistry.RegisterPermission(PermissionNames.ChangeDepartment, PermissionCategories.Department, Resources.CanChangeDepartment);
            foreach (var department in AppServices.MainDataContext.Departments)
            {
                PermissionRegistry.RegisterPermission(PermissionNames.UseDepartment + department.Id, PermissionCategories.Department, department.Name);
            }

            EventServiceFactory.EventService.GetEvent<GenericEvent<VisibleViewModelBase>>().Subscribe(s =>
            {
                if (s.Topic == EventTopicNames.ViewClosed)
                {
                    if (s.Value == _menuItemListViewModel)
                        _menuItemListViewModel = null;

                    if (s.Value == _screenMenuListViewModel)
                        _screenMenuListViewModel = null;

                    if (s.Value == _departmentListViewModel)
                        _departmentListViewModel = null;

                    if (s.Value == _menuItemPropertyGroupListViewModel)
                        _menuItemPropertyGroupListViewModel = null;

                    if (s.Value == _priceListViewModel)
                        _priceListViewModel = null;

                    if (s.Value == _ticketTagGroupListViewModel)
                        _ticketTagGroupListViewModel = null;

                    if (s.Value == _menuItemPriceDefinitionListViewModel)
                        _menuItemPriceDefinitionListViewModel = null;

                    if (s.Value == _vatTemplateListViewModel)
                        _vatTemplateListViewModel = null;

                    if (s.Value == _taxServiceTemplateListViewModel)
                        _taxServiceTemplateListViewModel = null;
                }
            });
        }
        public async Task CreateCategorySetsLinkCountToZeroWhenNoExistingCategoryTest()
        {
            var expected = Model.Create <NewCategory>();

            var store = Substitute.For <ICategoryStore>();
            var cache = Substitute.For <ICategoryCache>();

            var sut = new CategoryCommand(store, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                await sut.CreateCategory(expected, tokenSource.Token).ConfigureAwait(false);

                await store.Received().StoreCategory(Arg.Is <Category>(x => x.LinkCount == 0), tokenSource.Token)
                .ConfigureAwait(false);
            }
        }
        public void UpdateCategoryThrowsExceptionWhenCategoryNotFoundTest()
        {
            var expected = Model.Create <Category>();

            var store = Substitute.For <ICategoryStore>();
            var cache = Substitute.For <ICategoryCache>();

            var sut = new CategoryCommand(store, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                Func <Task> action = async() =>
                                     await sut.UpdateCategory(expected, tokenSource.Token).ConfigureAwait(false);

                action.Should().Throw <NotFoundException>();
            }
        }
Exemple #18
0
        public InventoryModule()
        {
            ListInventoryItemsCommand = new CategoryCommand <string>(Resources.InventoryItems, Resources.Products, OnListInventoryItems)
            {
                Order = 26
            };
            ListRecipesCommand = new CategoryCommand <string>(Resources.Recipes, Resources.Products, OnListRecipes)
            {
                Order = 27
            };
            ListTransactionsCommand = new CategoryCommand <string>(Resources.Transactions, Resources.Products, OnListTransactions)
            {
                Order = 28
            };
            ListPeriodicConsumptionsCommand = new CategoryCommand <string>(Resources.EndOfDayRecords, Resources.Products, OnListPeriodicConsumptions)
            {
                Order = 29
            };

            EventServiceFactory.EventService.GetEvent <GenericEvent <VisibleViewModelBase> >().Subscribe(s =>
            {
                if (s.Topic == EventTopicNames.ViewClosed)
                {
                    if (s.Value == _inventoryItemListViewModel)
                    {
                        _inventoryItemListViewModel = null;
                    }
                    if (s.Value == _recipeListViewModel)
                    {
                        _recipeListViewModel = null;
                    }
                    if (s.Value == _transactionListViewModel)
                    {
                        _transactionListViewModel = null;
                    }
                    if (s.Value == _periodicConsumptionListViewModel)
                    {
                        _periodicConsumptionListViewModel = null;
                    }
                }
            });

            EventServiceFactory.EventService.GetEvent <GenericEvent <WorkPeriod> >().Subscribe(OnWorkperiodStatusChanged);
        }
        public async Task UpdateCategorySetsReviewedToTrueTest()
        {
            var expected = Model.Create <Category>().Set(x => x.Reviewed = false);
            var category = Model.Create <Category>().Set(x => x.Group = expected.Group).Set(x => x.Name = expected.Name);

            var store = Substitute.For <ICategoryStore>();
            var cache = Substitute.For <ICategoryCache>();

            var sut = new CategoryCommand(store, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                store.GetCategory(expected.Group, expected.Name, tokenSource.Token).Returns(category);

                await sut.UpdateCategory(expected, tokenSource.Token).ConfigureAwait(false);

                await store.Received().StoreCategory(Arg.Is <Category>(x => x.Reviewed), tokenSource.Token)
                .ConfigureAwait(false);
            }
        }
Exemple #20
0
        public async Task <ActionResult> Save([FromBodyOrDefault] CategoryCommand cmd)
        {
            var cat = await CategoryService.GetByIdAsync(cmd.Id);

            if (cat == null)
            {
                var category = Mapper.Map <Category>(cmd);
                category.Path = cmd.ParentId > 0 ? (CategoryService[cmd.ParentId.Value].Path + "," + cmd.ParentId).Trim(',') : SnowFlake.NewId;
                var b1 = await CategoryService.AddEntitySavedAsync(category) > 0;

                return(ResultData(null, b1, b1 ? "分类添加成功!" : "分类添加失败!"));
            }

            cat.Name        = cmd.Name;
            cat.Description = cmd.Description;
            cat.ParentId    = cmd.ParentId;
            cat.Path        = cmd.ParentId > 0 ? (CategoryService[cmd.ParentId.Value].Path + "," + cmd.ParentId).Trim(',') : SnowFlake.NewId;
            bool b = await CategoryService.SaveChangesAsync() > 0;

            return(ResultData(null, b, b ? "分类修改成功!" : "分类修改失败!"));
        }
        public ActionResult New(CategoryViewModel model)
        {
            // Add it to http context
            try
            {
                var command = new CategoryCommand()
                {
                    Name             = model.Name,
                    Code             = model.Code,
                    CRMCode          = model.CRMCode,
                    Type             = model.Type,
                    ShortDescription = model.ShortDescription,
                    LongDescription  = model.LongDescription,
                    SortOrder        = model.SortOrder,
                    Status           = model.Status,
                    Environment      = this.Environment,
                    UserToken        = this.UserToken,
                    SessionId        = this.SessionId
                };

                var response = _metadataServiceClient.CreateCategory(command);

                model.CategoryId = response.CategoryId;

                if (response.Errors.Any())
                {
                    model.Errors = response.Errors;
                }
            }
            catch (Exception ex)
            {
                Log(LogMode.Error, "There is an error while creating a category!", ex);

                model.Errors.Add(ex.Message);

                return(RedirectToAction("Details", new { id = model.CategoryId }));
            }

            return(RedirectToAction("Details", new { id = model.CategoryId }));
        }
        public async Task UpdateCategoryPreservesExistingLinkCountWhenCategoryAlreadyExistsTest()
        {
            var expected = Model.Create <Category>();
            var category = Model.Create <Category>().Set(x => x.Group = expected.Group).Set(x => x.Name = expected.Name);

            var store = Substitute.For <ICategoryStore>();
            var cache = Substitute.For <ICategoryCache>();

            var sut = new CategoryCommand(store, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                store.GetCategory(expected.Group, expected.Name, tokenSource.Token).Returns(category);

                await sut.UpdateCategory(expected, tokenSource.Token).ConfigureAwait(false);

                await store.Received(1).StoreCategory(Arg.Any <Category>(), tokenSource.Token).ConfigureAwait(false);

                await store.Received().StoreCategory(
                    Arg.Is <Category>(x => x.Group == expected.Group),
                    tokenSource.Token).ConfigureAwait(false);

                await store.Received().StoreCategory(Arg.Is <Category>(x => x.Name == expected.Name), tokenSource.Token)
                .ConfigureAwait(false);

                await store.Received().StoreCategory(
                    Arg.Is <Category>(x => x.LinkCount == category.LinkCount),
                    tokenSource.Token).ConfigureAwait(false);

                await store.Received().StoreCategory(Arg.Is <Category>(x => x.Reviewed), tokenSource.Token)
                .ConfigureAwait(false);

                await store.Received()
                .StoreCategory(Arg.Is <Category>(x => x.Visible == expected.Visible), tokenSource.Token)
                .ConfigureAwait(false);

                cache.Received().RemoveCategories();
            }
        }
Exemple #23
0
        public InventoryModule()
        {
            ListInventoryItemsCommand = new CategoryCommand<string>(Resources.InventoryItems, Resources.Products, OnListInventoryItems) { Order = 26 };
            ListRecipesCommand = new CategoryCommand<string>(Resources.Recipes, Resources.Products, OnListRecipes) { Order = 27 };
            ListTransactionsCommand = new CategoryCommand<string>(Resources.Transactions, Resources.Products, OnListTransactions) { Order = 28 };
            ListPeriodicConsumptionsCommand = new CategoryCommand<string>(Resources.EndOfDayRecords, Resources.Products, OnListPeriodicConsumptions) { Order = 29 };

            EventServiceFactory.EventService.GetEvent<GenericEvent<VisibleViewModelBase>>().Subscribe(s =>
            {
                if (s.Topic == EventTopicNames.ViewClosed)
                {
                    if (s.Value == _inventoryItemListViewModel)
                        _inventoryItemListViewModel = null;
                    if (s.Value == _recipeListViewModel)
                        _recipeListViewModel = null;
                    if (s.Value == _transactionListViewModel)
                        _transactionListViewModel = null;
                    if (s.Value == _periodicConsumptionListViewModel)
                        _periodicConsumptionListViewModel = null;
                }
            });

            EventServiceFactory.EventService.GetEvent<GenericEvent<WorkPeriod>>().Subscribe(OnWorkperiodStatusChanged);
        }
Exemple #24
0
        public SettingsModule(IRegionManager regionManager, WorkPeriodsView workPeriodsView)
        {
            _regionManager = regionManager;
            _workPeriodsView = workPeriodsView;

            NavigateWorkPeriodsCommand = new CategoryCommand<string>(Resources.DayOperations, Resources.Common, "Images/Run.png", OnNavigateWorkPeriods, CanNavigateWorkPeriods);

            ListProgramSettingsCommand = new CategoryCommand<string>(Resources.LocalSettings, Resources.Settings, OnListProgramSettings);
            ListTerminalsCommand = new CategoryCommand<string>(Resources.Terminals, Resources.Settings, OnListTerminals);
            ListPrintersCommand = new CategoryCommand<string>(Resources.Printers, Resources.Settings, OnListPrinters);
            ListPrintJobsCommand = new CategoryCommand<string>(Resources.PrintJobs, Resources.Settings, OnListPrintJobs);
            ListPrinterTemplatesCommand = new CategoryCommand<string>(Resources.PrinterTemplates, Resources.Settings, OnListPrinterTemplates);
            ListNumeratorsCommand = new CategoryCommand<string>(Resources.Numerators, Resources.Settings, OnListNumerators);
            ListVoidReasonsCommand = new CategoryCommand<string>(Resources.VoidReasons, Resources.Products, OnListVoidReasons);
            ListGiftReasonsCommand = new CategoryCommand<string>(Resources.GiftReasons, Resources.Products, OnListGiftReasons);
            ListMenuItemSettingsCommand = new CategoryCommand<string>(Resources.ProgramSettings, Resources.Settings, OnListMenuItemSettings) { Order = 10 };
            ListRuleActionsCommand = new CategoryCommand<string>(Resources.RuleActions, Resources.Settings, OnListRuleActions);
            ListRulesCommand = new CategoryCommand<string>(Resources.Rules, Resources.Settings, OnListRules);
            ListTriggersCommand = new CategoryCommand<string>(Resources.Triggers, Resources.Settings, OnListTriggers);

            ShowBrowser = new CategoryCommand<string>(Resources.SambaPosWebsite, Resources.SambaNetwork, OnShowBrowser) { Order = 99 };

            PermissionRegistry.RegisterPermission(PermissionNames.OpenWorkPeriods, PermissionCategories.Navigation, Resources.CanStartEndOfDay);
            PermissionRegistry.RegisterPermission(PermissionNames.CloseActiveWorkPeriods, PermissionCategories.Navigation, Resources.ForceClosingActiveWorkPeriod);

            EventServiceFactory.EventService.GetEvent<GenericEvent<VisibleViewModelBase>>().Subscribe(s =>
            {
                if (s.Topic == EventTopicNames.ViewClosed)
                {
                    if (s.Value == _settingsViewModel)
                        _settingsViewModel = null;

                    if (s.Value == _terminalListViewModel)
                        _terminalListViewModel = null;

                    if (s.Value == _printerListViewModel)
                        _printerListViewModel = null;

                    if (s.Value == _printerTemplateCollectionViewModel)
                        _printerTemplateCollectionViewModel = null;

                    if (s.Value == _printJobsViewModel)
                        _printJobsViewModel = null;

                    if (s.Value == _numeratorListViewModel)
                        _numeratorListViewModel = null;

                    if (s.Value == _voidReasonListViewModel)
                        _voidReasonListViewModel = null;

                    if (s.Value == _giftReasonListViewModel)
                        _giftReasonListViewModel = null;

                    if (s.Value == _ruleActionListViewModel)
                        _ruleActionListViewModel = null;

                    if (s.Value == _ruleListViewModel)
                        _ruleListViewModel = null;

                    if (s.Value == _triggerListViewModel)
                        _triggerListViewModel = null;
                }
            });
        }
        public ActionResult Details(CategoryViewModel model)
        {
            try
            {
                // Get the exist category
                var category = _metadataServiceClient.GetCategories(new CategoryQuery()
                {
                    CategoryIds = new List <int> {
                        model.CategoryId
                    },
                    Environment = this.Environment,
                    UserToken   = this.UserToken,
                    SessionId   = this.SessionId,
                    Envelope    = "full"
                }).Result.FirstOrDefault();

                var command = new CategoryCommand()
                {
                    CategoryId       = model.CategoryId,
                    ParentId         = model.ParentId,
                    Name             = model.Name,
                    Code             = model.Code,
                    CRMCode          = model.CRMCode,
                    Type             = model.Type,
                    ShortDescription = model.ShortDescription,
                    LongDescription  = model.LongDescription,
                    SortOrder        = model.SortOrder,
                    Status           = model.Status,
                    Environment      = this.Environment,
                    UserToken        = this.UserToken,
                    SessionId        = this.SessionId
                };

                var response = _metadataServiceClient.UpdateCategory(command);

                if (response.Errors.Any())
                {
                    response.Errors.ForEach(error => model.Errors.Add(error));
                }

                #region [ Breadcrumb ]

                // Create the breadcrumb
                var breadcrumb = new List <BreadcrumbItemViewModel>();
                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = "Kategoriler",
                    Link = "/Categories"
                });

                breadcrumb.Add(new BreadcrumbItemViewModel()
                {
                    Text = model.Name
                });

                ViewBag.Breadcrumb = breadcrumb;

                #endregion
            }
            catch (Exception ex)
            {
                Log(LogMode.Error, $"There is an error while updating the category details! CategoryId:{model.CategoryId}", ex);
                model.Errors.Add(ex.Message);
                return(View("Details", model));
            }
            return(RedirectToAction("Details", new { id = model.CategoryId }));
        }
Exemple #26
0
 public HomeVM()
 {
     Category        = new Category();
     CategoryCommand = new CategoryCommand(this);
 }
    public static void ListCommands(Player player)
    {
        var dialog = new ListDialog("Menu", "Seleccionar", "Cerrar");

        dialog.AddItems(new[]
        {
            "General",
            "Armas",
            "Mensajes Privados",
            "AFK",
            "Estadísticas",
            "Atajos",
            "Signos",
            "Otros comandos"
        });
        var category = new CategoryCommand()
        {
            DialogMain = dialog
        };

        dialog.Response += (sender, e) =>
        {
            if (e.DialogButton == DialogButton.Left)
            {
                category.DialogCategory.Message = "";
                category.DialogCategory.Caption = dialog.Items[e.ListItem];
                switch (e.ListItem)
                {
                case 0:
                    category.ShowGeneral();
                    break;

                case 1:
                    category.ShowWeapons();
                    break;

                case 2:
                    category.ShowPM();
                    break;

                case 3:
                    category.ShowAFK();
                    break;

                case 4:
                    category.ShowStats();
                    break;

                case 5:
                    category.ShowShortcurts();
                    break;

                case 6:
                    category.ShowSigns();
                    break;

                case 7:
                    category.ShowOthers();
                    break;
                }
                category.DialogCategory.Show(player);
            }
        };
        dialog.Show(player);
    }
Exemple #28
0
        public SettingsModule(IRegionManager regionManager, WorkPeriodsView workPeriodsView)
        {
            _regionManager   = regionManager;
            _workPeriodsView = workPeriodsView;

            NavigateWorkPeriodsCommand = new CategoryCommand <string>(Resources.DayOperations, Resources.Common, "Images/Run.png", OnNavigateWorkPeriods, CanNavigateWorkPeriods);

            ListProgramSettingsCommand  = new CategoryCommand <string>(Resources.LocalSettings, Resources.Settings, OnListProgramSettings);
            ListTerminalsCommand        = new CategoryCommand <string>(Resources.Terminals, Resources.Settings, OnListTerminals);
            ListPrintersCommand         = new CategoryCommand <string>(Resources.Printers, Resources.Settings, OnListPrinters);
            ListPrintJobsCommand        = new CategoryCommand <string>(Resources.PrintJobs, Resources.Settings, OnListPrintJobs);
            ListPrinterTemplatesCommand = new CategoryCommand <string>(Resources.PrinterTemplates, Resources.Settings, OnListPrinterTemplates);
            ListNumeratorsCommand       = new CategoryCommand <string>(Resources.Numerators, Resources.Settings, OnListNumerators);
            ListVoidReasonsCommand      = new CategoryCommand <string>(Resources.VoidReasons, Resources.Products, OnListVoidReasons);
            ListGiftReasonsCommand      = new CategoryCommand <string>(Resources.GiftReasons, Resources.Products, OnListGiftReasons);
            ListMenuItemSettingsCommand = new CategoryCommand <string>(Resources.ProgramSettings, Resources.Settings, OnListMenuItemSettings)
            {
                Order = 10
            };
            ListRuleActionsCommand = new CategoryCommand <string>(Resources.RuleActions, Resources.Settings, OnListRuleActions);
            ListRulesCommand       = new CategoryCommand <string>(Resources.Rules, Resources.Settings, OnListRules);
            ListTriggersCommand    = new CategoryCommand <string>(Resources.Triggers, Resources.Settings, OnListTriggers);

            ShowBrowser = new CategoryCommand <string>(Resources.SambaPosWebsite, Resources.SambaNetwork, OnShowBrowser)
            {
                Order = 99
            };

            PermissionRegistry.RegisterPermission(PermissionNames.OpenWorkPeriods, PermissionCategories.Navigation, Resources.CanStartEndOfDay);
            PermissionRegistry.RegisterPermission(PermissionNames.CloseActiveWorkPeriods, PermissionCategories.Navigation, Resources.ForceClosingActiveWorkPeriod);

            EventServiceFactory.EventService.GetEvent <GenericEvent <VisibleViewModelBase> >().Subscribe(s =>
            {
                if (s.Topic == EventTopicNames.ViewClosed)
                {
                    if (s.Value == _settingsViewModel)
                    {
                        _settingsViewModel = null;
                    }

                    if (s.Value == _terminalListViewModel)
                    {
                        _terminalListViewModel = null;
                    }

                    if (s.Value == _printerListViewModel)
                    {
                        _printerListViewModel = null;
                    }

                    if (s.Value == _printerTemplateCollectionViewModel)
                    {
                        _printerTemplateCollectionViewModel = null;
                    }

                    if (s.Value == _printJobsViewModel)
                    {
                        _printJobsViewModel = null;
                    }

                    if (s.Value == _numeratorListViewModel)
                    {
                        _numeratorListViewModel = null;
                    }

                    if (s.Value == _voidReasonListViewModel)
                    {
                        _voidReasonListViewModel = null;
                    }

                    if (s.Value == _giftReasonListViewModel)
                    {
                        _giftReasonListViewModel = null;
                    }

                    if (s.Value == _ruleActionListViewModel)
                    {
                        _ruleActionListViewModel = null;
                    }

                    if (s.Value == _ruleListViewModel)
                    {
                        _ruleListViewModel = null;
                    }

                    if (s.Value == _triggerListViewModel)
                    {
                        _triggerListViewModel = null;
                    }
                }
            });
        }
Exemple #29
0
        public MenuModule()
        {
            ListDepartmentsCommand            = new CategoryCommand <string>(Resources.Departments, Resources.Settings, OnListDepartments);
            ListMenuItemsCommand              = new CategoryCommand <string>(Resources.ProductList, Resources.Products, OnListMenuItems);
            ListScreenMenusCommand            = new CategoryCommand <string>(Resources.MenuList, Resources.Products, OnListScreenMenus);
            ListMenuItemPropertyGroupsCommand = new CategoryCommand <string>(Resources.ModifierGroups, Resources.Products, OnListMenuItemPropertyGroupsCommand);
            ListPricesCommand          = new CategoryCommand <string>(Resources.BatchPriceList, Resources.Products, OnListPrices);
            ListTicketTagGroupsCommand = new CategoryCommand <string>(Resources.TicketTags, Resources.Settings, OnListTicketTags)
            {
                Order = 10
            };
            ListMenuItemPriceDefinitionsCommand = new CategoryCommand <string>(Resources.PriceDefinitions, Resources.Products, OnListMenuItemPriceDefinitions);
            ListVatTemplatesCommand             = new CategoryCommand <string>(Resources.VatTemplates, Resources.Products, OnListVatTemplates);
            ListTaxServiceTemplates             = new CategoryCommand <string>(Resources.TaxServiceTemplates, Resources.Products, OnListTaxServiceTemplates);

            PermissionRegistry.RegisterPermission(PermissionNames.ChangeDepartment, PermissionCategories.Department, Resources.CanChangeDepartment);
            foreach (var department in AppServices.MainDataContext.Departments)
            {
                PermissionRegistry.RegisterPermission(PermissionNames.UseDepartment + department.Id, PermissionCategories.Department, department.Name);
            }

            EventServiceFactory.EventService.GetEvent <GenericEvent <VisibleViewModelBase> >().Subscribe(s =>
            {
                if (s.Topic == EventTopicNames.ViewClosed)
                {
                    if (s.Value == _menuItemListViewModel)
                    {
                        _menuItemListViewModel = null;
                    }

                    if (s.Value == _screenMenuListViewModel)
                    {
                        _screenMenuListViewModel = null;
                    }

                    if (s.Value == _departmentListViewModel)
                    {
                        _departmentListViewModel = null;
                    }

                    if (s.Value == _menuItemPropertyGroupListViewModel)
                    {
                        _menuItemPropertyGroupListViewModel = null;
                    }

                    if (s.Value == _priceListViewModel)
                    {
                        _priceListViewModel = null;
                    }

                    if (s.Value == _ticketTagGroupListViewModel)
                    {
                        _ticketTagGroupListViewModel = null;
                    }

                    if (s.Value == _menuItemPriceDefinitionListViewModel)
                    {
                        _menuItemPriceDefinitionListViewModel = null;
                    }

                    if (s.Value == _vatTemplateListViewModel)
                    {
                        _vatTemplateListViewModel = null;
                    }

                    if (s.Value == _taxServiceTemplateListViewModel)
                    {
                        _taxServiceTemplateListViewModel = null;
                    }
                }
            });
        }