public async Task <IActionResult> CreateTyre(CreateTyreDTO <SelectListItem> tyreModel) { if (ModelState.IsValid) { var isCreated = await this.tyreService.Create <SelectListItem>(tyreModel); if (isCreated) { TempData.AddSuccessMessage("Tyre was successful created."); } else { TempData.AddErrrorMessage("Tyre service error."); } } else { TempData.AddErrrorMessage("Invalid input data."); } return(RedirectToAction(nameof(CreateTyre))); }
public async Task <bool> Create <T>(CreateTyreDTO <T> model) { var tyre = new Tyre { Brand = model.Brand, Model = model.Model, Price = model.Price, Quantity = model.Quantity, Width = model.Width, Ratio = model.Ratio, Diameter = model.Diameter, Season = model.Season, Speed = model.Speed, Load = model.Load, FuelEfficient = model.FuelEfficient, WetGrip = model.WetGrip, Noice = model.Noice }; db.Tyres.Add(tyre); await db.SaveChangesAsync(); return(true); }