public async Task <IActionResult> Create([Bind("Id,ColorName")] Color color)
        {
            if (ModelState.IsValid)
            {
                _context.Add(color);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(color));
        }
        public async Task <IActionResult> Create([Bind("Id,DealerName,WebsiteAddress,Description")] AuthorizedDealer authorizedDealer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(authorizedDealer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(authorizedDealer));
        }
        public async Task <IActionResult> Create([Bind("Id,SizeId,ColorId,ModelId")] SizeColorModel sizeColorModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sizeColorModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ColorId"] = new SelectList(_context.Colors, "Id", "ColorName", sizeColorModel.ColorId);
            ViewData["ModelId"] = new SelectList(_context.BicycleModels, "Id", "ModelName", sizeColorModel.ModelId);
            ViewData["SizeId"]  = new SelectList(_context.Sizes, "Id", "SizeName", sizeColorModel.SizeId);
            return(View(sizeColorModel));
        }
        public IActionResult Create(BicycleModelViewModel bvm)
        {
            BicycleModel bicycleModel = new BicycleModel
            {
                BrandId    = bvm.BrandId,
                CategoryId = bvm.CategoryId,
                GenderId   = bvm.GenderId,

                Description     = bvm.Description,
                Id              = bvm.Id,
                ModelName       = bvm.ModelName,
                ModelYear       = bvm.ModelYear,
                Price           = bvm.Price,
                SizeColorModels = bvm.SizeColorModels
            };

            if (ModelState.IsValid)
            {
                if (bvm.Image != null)
                {
                    byte[] imageData = null;
                    using (var binaryReader = new BinaryReader(bvm.ImageFile.OpenReadStream()))
                    {
                        imageData = binaryReader.ReadBytes((int)bvm.Image.Length);
                    }
                    bicycleModel.Image = imageData;
                }
                _context.Add(bicycleModel);
                _context.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"]    = new SelectList(_context.Brands, "Id", "BrandName", bicycleModel.BrandId);
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "CategoryName", bicycleModel.CategoryId);
            ViewData["GenderId"]   = new SelectList(_context.Genders, "Id", "GenderName", bicycleModel.GenderId);
            return(View(bicycleModel));
        }