public async Task <IActionResult> Create(CreateMileViewModel model) { if (ModelState.IsValid) { var client = await _clientRepository .GetClientByNumberAsync(model.MilesProgramNumber); if (client == null) { ModelState.AddModelError(string.Empty, "Client does not exist"); model.MilesType = _combosHelper.GetComboMilesTypes(); return(View(model)); } var milesType = await _milesTypeRepository .GetByIdAsync(model.MilesTypeId); if (milesType == null) { ModelState.AddModelError(string.Empty, "Type does not exist"); model.MilesType = _combosHelper.GetComboMilesTypes(); return(View(model)); } var mile = _converterHelper.CreateMileViewModelToMile(model, client, milesType); await _mileRepository.CreateAsync(mile); return(RedirectToAction(nameof(Index))); } return(View(model)); }