示例#1
0
        public IActionResult Upsert(int?id)
        {
            ProductViewModel productVM = new ProductViewModel()
            {
                Product      = new BulkyBook.Models.Product(),
                CategoryList = _categoryRepository.GetAll().Select(i => new SelectListItem
                {
                    Text  = i.Name,
                    Value = i.Id.ToString(),
                }),
                CoverTypeList = _coverTypeRepository.GetAll().Select(i => new SelectListItem
                {
                    Text  = i.Name,
                    Value = i.Id.ToString()
                })
            };

            BulkyBook.Models.Product product = new BulkyBook.Models.Product(); //SOME ERROR with Single class initialization.
            if (id == null)
            {
                // Create
                return(View(productVM));
            }
            // Update
            productVM.Product = _productRepository.GetById(id.GetValueOrDefault());
            if (productVM.Product == null)
            {
                // Incorrect ID
                return(NotFound());
            }
            return(View(productVM));
        }
示例#2
0
        public async Task OnGetAsync(string returnUrl = null)
        {
            ReturnUrl = returnUrl;

            // Including dropdown box in register page
            Input = new InputModel()
            {
                CompanyList = _repoCoverType.GetAll().Select(i => new SelectListItem
                {
                    Text  = i.Name,
                    Value = i.Id.ToString()
                }),

                RoleList = _roleManager.Roles.Where(u => u.Name != SD.Role_User).Select(x => x.Name).Select(i => new SelectListItem
                {
                    Text  = i,
                    Value = i
                })
            };


            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
        }
        public IActionResult GetAll()
        {
            var categories = _coverTypeRepository.GetAll();

            return(Json(new { data = categories }));
        }