public IActionResult Create(CarCreationViewModel data) { if (m_userData.Get(m_userManager.GetUserId(User)).Type != UserType.Manager) { return(Content("Oops! Nothing to see here.")); } if (!ModelState.IsValid) { return(View(data)); } ValidateCarData(data, ModelState); if (!ModelState.IsValid) { return(View(data)); } Car created = new Car { Brand = data.Brand, Gearbox = data.Gearbox, LicensePlate = data.LicensePlate, ManufactureDate = data.ManufactureDate, Mileage = data.Mileage, Model = data.Model }; m_carData.Add(created); m_documentData.UpdateCarsDocuments(created, data.Documents); m_mileagePointData.UpdateCarsMileagePoints(created, data.MileagePoints. Select(p => p as MileagePointBase).ToList()); m_carData.SaveChanges(); m_carData.UpdateState(created.Id); m_carData.SaveChanges(); return(RedirectToAction("ViewCarList")); }