public async Task <ActionResult> Create(CreateSensorTypeViewModel sensorTypeViewModel) { if (!ModelState.IsValid) { return(View(sensorTypeViewModel)); } SensorTypeDto sensorTypeDto = _mapper.Map <CreateSensorTypeViewModel, SensorTypeDto>(sensorTypeViewModel); if (sensorTypeViewModel.IconFile != null) { sensorTypeDto.IconId = await _iconManager.CreateAndGetIconId(sensorTypeViewModel.IconFile); } var res = _sensorTypeManager.Create(sensorTypeDto).Result; if (res != null) { return(ViewComponent("SensorTypeElement", _mapper.Map <SensorTypeDto, SensorTypeViewModel>(res))); } else { //ModelState.AddModelError(res.Property, res.Message); return(View(sensorTypeViewModel)); } }
public IViewComponentResult Invoke(CreateSensorTypeViewModel model) => View(model);