Ejemplo n.º 1
0
        public AdminMenuViewModel Count(AdminMenuViewModel adminMenuViewModel)
        {
            adminMenuViewModel.AdvertsCount  = CountAdvert();
            adminMenuViewModel.MessagesCount = CountMessages();

            return(adminMenuViewModel);
        }
Ejemplo n.º 2
0
 public PartialViewResult Menu(string selectedCategory)
 {
     AdminMenuViewModel[] dataList = new AdminMenuViewModel[] {
         new AdminMenuViewModel {
             ControllerName = "Admin", ActionName = "UserIndex", DisplayName = "會員清單"
         },
         new AdminMenuViewModel {
             ControllerName = "Admin", ActionName = "ProductIndex", DisplayName = "產品清單"
         },
         new AdminMenuViewModel {
             ControllerName = "Admin", ActionName = "ProductCreate", DisplayName = "產品新增"
         },
         new AdminMenuViewModel {
             ControllerName = "Admin", ActionName = "OrderIndex", DisplayName = "訂單總覽"
         },
         new AdminMenuViewModel {
             ControllerName = "RoleAdmin", ActionName = "Index", DisplayName = "權限設定"
         },
         new AdminMenuViewModel {
             ControllerName = "Admin", ActionName = "ProductCateAndBrandIndex", DisplayName = "產品廠商與類別"
         }
     };
     if (selectedCategory == null || !dataList.Select(a => a.ActionName).Contains(selectedCategory))
     {
         selectedCategory = "UserIndex";
     }
     ViewBag.SelectedCategory = selectedCategory;
     return(PartialView("~/Views/Admin/_Menu.cshtml", dataList));
 }
Ejemplo n.º 3
0
        private AdminMenuViewModel CreateViewModel()
        {
            AdminMenuViewModel adminMenuViewModel = new AdminMenuViewModel();

            adminMenuViewModel.manageCategoryAction += OpenManageCategoryWindow;
            adminMenuViewModel.manageProductAction  += OpenManageProductWindow;
            adminMenuViewModel.logoutAction         += OpenLoginWindow;
            return(adminMenuViewModel);
        }
Ejemplo n.º 4
0
        public ActionResult Menu()
        {
            var model = new AdminMenuViewModel();

            model.AdvertTypes = _getAvailableAdvertTypes.GetAdvertTypeNameAndMask();
            model             = _countMessagesAndAdverts.Count(model);

            return(View("_AdminMenu", model));
        }
Ejemplo n.º 5
0
        public PartialViewResult AdminMenu(string activeMenu = "")
        {
            var model = new AdminMenuViewModel()
            {
                AdminMenu          = AsyncHelper.RunSync(() => _userNavigationManager.GetMenuAsync("AdminMenu", AbpSession.ToUserIdentifier())),
                ActiveMenuItemName = activeMenu
            };

            return(PartialView("_AdminMenu", model));
        }
Ejemplo n.º 6
0
        // GET: api/AdminMenu
        public HttpResponseMessage GetMenus()
        {
            try
            {
                if (User.Identity.IsAuthenticated)
                {
                    var userId         = User.Identity.GetUserId();
                    var menuResultList = new List <AdminMenuViewModel>();
                    var parentMenuList = new List <AdminMenu>();

                    if (UserManager.IsInRole(userId, "Admin"))
                    {
                        parentMenuList = _adminMenuService.GetMany(m => m.Parent == 0 &&
                                                                   m.Available == true)
                                         .OrderBy(m => m.Order).ToList();
                    }
                    else
                    {
                        parentMenuList = _adminMenuService.GetMany(m => m.Parent == 0 &&
                                                                   m.IsAdmin == false &&
                                                                   m.Available == true)
                                         .OrderBy(m => m.Order).ToList();
                    }

                    foreach (var menu in parentMenuList)
                    {
                        var menuResult = new AdminMenuViewModel()
                        {
                            Name      = menu.Name,
                            Url       = menu.Url,
                            CssIcon   = menu.CssIcon,
                            LabelCss  = menu.LabelCss,
                            Type      = menu.Type,
                            Parent    = menu.Parent,
                            Order     = menu.Order,
                            Available = menu.Available,
                            Childs    = GetChilds(menu.Id)
                        };
                        menuResultList.Add(menuResult);
                    }

                    return(Request.CreateResponse(HttpStatusCode.OK, menuResultList));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError));
                }
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));

                throw;
            }
        }
Ejemplo n.º 7
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var user = _userManager.GetUserAsync(HttpContext.User).Result;
            //var isProductManager = await _userManager.IsInRoleAsync(user, CommonConstants.ProductManagerRoleName);
            var numberOfOrdersInProgress = _orderRepository.GetSome(o => o.IsDeleted == false && o.Status == DAL.Data.Enums.OrderStatus.Pending).Count();
            var viewModel = new AdminMenuViewModel
            {
                NumberOfOrdersInProgress = numberOfOrdersInProgress,
                IsProductManager         = user != null ? await _userManager.IsInRoleAsync(user, CommonConstants.ProductManagerRoleName) : false,
                IsStoreOwner             = user != null ? await _userManager.IsInRoleAsync(user, CommonConstants.StoreOwnerRoleName) : false,
                IsOrderManager           = user != null ? await _userManager.IsInRoleAsync(user, CommonConstants.OrderManagerRoleName) : false
            };

            return(View(viewModel));
        }
Ejemplo n.º 8
0
        public AdminMenu()
        {
            InitializeComponent();
            DoubleAnimation buttonAnimation = new DoubleAnimation();

            buttonAnimation.From     = BtnProject.ActualWidth;
            buttonAnimation.To       = 290;
            buttonAnimation.Duration = TimeSpan.FromSeconds(2);
            BtnProject.BeginAnimation(Button.WidthProperty, buttonAnimation);

            AdminMenuViewModel adminMenuVM = new AdminMenuViewModel();

            DataContext = adminMenuVM;
            adminMenuVM.ClosingRequest += (sender, e) => Close();
        }
Ejemplo n.º 9
0
 public AdminNavController()
 {
     MenuViewModel = new AdminMenuViewModel
     {
         MenuItems = new List <MenuItem>
         {
             new MenuItem {
                 Name = "Продукты", Controller = "AdminProduct", Action = "Index"
             },
             new MenuItem {
                 Name = "Категории", Controller = "Categories", Action = "List"
             }
         },
         CurMenuItem = null
     };
 }
Ejemplo n.º 10
0
        public IActionResult Index(int page = 0)
        {
            AdminMenuViewModel   viewModel   = new AdminMenuViewModel();
            AdminMenuFilterInput filterInput = GetFilterInSession <AdminMenuFilterInput>(ConstantConfig.SessionName.AdminMenuSession);

            if (filterInput == null)
            {
                filterInput = new AdminMenuFilterInput
                {
                    RecordStatus = ConstantConfig.RecordStatusConfig.Active
                };
            }
            filterInput.PageNumber         = page;
            viewModel.PagingResult         = adminMenuAdminService.GetAllByPaging(filterInput);
            viewModel.AdminMenuFilterInput = filterInput;
            ViewBag.AdminMenuCombobox      = adminMenuAdminService.GetAdminMenusCombobox();

            InitAdminBaseViewModel(viewModel);
            return(View(viewModel));
        }
Ejemplo n.º 11
0
        public List <AdminMenuViewModel> GetChilds(int ParentId)
        {
            var childsList   = _adminMenuService.GetMany(m => m.Parent == ParentId).ToList();
            var childsListVM = new List <AdminMenuViewModel>();

            foreach (var menu in childsList)
            {
                var menuResult = new AdminMenuViewModel()
                {
                    Name      = menu.Name,
                    Url       = menu.Url,
                    CssIcon   = menu.CssIcon,
                    LabelCss  = menu.LabelCss,
                    Type      = menu.Type,
                    Parent    = menu.Parent,
                    Order     = menu.Order,
                    Available = menu.Available,
                    Childs    = GetChilds(menu.Id)
                };
                childsListVM.Add(menuResult);
            }
            return(childsListVM);
        }
Ejemplo n.º 12
0
        public List <AdminMenuViewModel> GetAllMenuFunction()
        {
            List <AdminMenuViewModel> adminLayoutViewModel = new List <AdminMenuViewModel>();
            var mainFunction = new Function();

            mainFunction.function_id        = 0;
            mainFunction.function_state     = 0;
            mainFunction.function_father_id = 0;
            var functionList = funDao.Select(mainFunction);

            foreach (var item in functionList)
            {
                item.function_father_id = item.function_id;
                item.function_id        = 0;
                var chiledFunctions  = funDao.Select(item);
                AdminMenuViewModel m = new AdminMenuViewModel();
                m.function       = item;
                m.chiledFunction = chiledFunctions;
                adminLayoutViewModel.Add(m);
            }


            return(adminLayoutViewModel);
        }
 /// <summary>
 /// 画面が読み込まれた後に呼ばれます。
 /// </summary>
 /// <param name="sender">sender</param>
 /// <param name="e">e</param>
 private void ViewLoaded(object sender, RoutedEventArgs e)
 {
     this.viewModel = this.DataContext as AdminMenuViewModel;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// ログインボタンが押されたときに呼ばれます。
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private async void LoginButtonClick(object sender, RoutedEventArgs e)
        {
            this.btnLogin.IsEnabled = false;

            if (!this.ValidateLogin())
            {
                return;
            }

            try
            {
                var passwordHash = new HashCreater().CreateSHA256Hash(this.txtPassword.Password);
                this.viewModel.AccessToken = await this.Login(this.viewModel.UserId, passwordHash);

                if (string.IsNullOrEmpty(this.viewModel.AccessToken))
                {
                    MessageBox.Show("ID、パスワードもしくは両方が間違っています。");
                    return;
                }

                UserModel user = await this.GetUser(this.viewModel.UserId, this.viewModel.AccessToken);

                if (user == null)
                {
                    return;
                }

                Window childView = null;

                // 管理者か否かによってメニューを分岐
                if (user.IsAdmin)
                {
                    var childViewModel = new AdminMenuViewModel();

                    childView                  = new AdminMenuView();
                    childViewModel.UserId      = this.viewModel.UserId;
                    childViewModel.DisplayName = user.DisplayName;
                    childViewModel.AccessToken = this.viewModel.AccessToken;
                    childView.DataContext      = childViewModel;
                }
                else
                {
                    var childViewModel = new UserMenuViewModel();

                    childView                  = new UserMenuView();
                    childViewModel.UserId      = this.viewModel.UserId;
                    childViewModel.DisplayName = user.DisplayName;
                    childViewModel.AccessToken = this.viewModel.AccessToken;
                    childView.DataContext      = childViewModel;
                }

                childView.Owner = this;
                this.Hide();
                childView.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                this.viewModel.UserId     = string.Empty;
                this.txtPassword.Password = string.Empty;
                this.btnLogin.IsEnabled   = true;
                this.Show();
                this.txtUserId.Focus();
            }
        }