Пример #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Link")] Menu menu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(menu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(menu));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] Property @property)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@property);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(@property));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,Link,MenuId")] SubMenu subMenu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subMenu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MenuId"] = new SelectList(_context.Menus, "Id", "Name", subMenu.MenuId);
            return(View(subMenu));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,MarkaId")] Model model)
        {
            if (ModelState.IsValid)
            {
                _context.Add(model);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MarkaId"] = new SelectList(_context.Markas, "Id", "Name", model.MarkaId);
            return(View(model));
        }
        public async Task <IActionResult> Create([Bind("Id,UserName,Description,ProductId")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(comment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", comment.ProductId);
            return(View(comment));
        }
        public async Task <IActionResult> Create([Bind("Id,Star,ProductId")] Rating rating)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rating);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", rating.ProductId);
            return(View(rating));
        }
Пример #7
0
        public async Task <IActionResult> Create([Bind("Value,ProductId,PropertyId")] ProductProperty productProperty)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productProperty);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"]  = new SelectList(_context.Products, "Id", "Name", productProperty.ProductId);
            ViewData["PropertyId"] = new SelectList(_context.Properties, "Id", "Name", productProperty.PropertyId);
            return(View(productProperty));
        }
        public async Task <IActionResult> Create(CategoryViewModel category)
        {
            if (ModelState.IsValid)
            {
                string   uniqueFileName = UploadedFile(category);
                Category newCategory    = new Category
                {
                    Name              = category.Name,
                    Image             = uniqueFileName,
                    Link              = category.Link,
                    ProductCategories = category.ProductCategories,
                    SubMenuId         = category.SubMenuId,
                    SubMenu           = category.SubMenu
                };
                _context.Add(newCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SubMenuId"] = new SelectList(_context.SubMenus, "Id", "Name", category.SubMenuId);
            return(View(category));
        }