public async Task <ActionResult> Edit(EditSensorTypeViewModel sensorTypeViewModel) { SensorTypeDto sensorTypeDto = _mapper.Map <EditSensorTypeViewModel, SensorTypeDto>(sensorTypeViewModel); IconDto iconDto = null; if (sensorTypeViewModel.IconFile != null) { sensorTypeDto.IconId = await _iconManager.CreateAndGetIconId(sensorTypeViewModel.IconFile); iconDto = await _iconManager.GetById(sensorTypeDto.IconId.GetValueOrDefault()); sensorTypeDto.IconPath = iconDto.Path; } var res = await _sensorTypeManager.Update(sensorTypeDto); if (res != null) { //res = await _sensorTypeManager.GetSensorTypeByIdAsync(sensorTypeDto.Id); iconDto = await _iconManager.GetById(sensorTypeDto.IconId.GetValueOrDefault()); sensorTypeDto.IconPath = iconDto.Path; return(ViewComponent("SensorTypeElement", _mapper.Map <SensorTypeDto, SensorTypeViewModel>(sensorTypeDto))); } else { //ModelState.AddModelError(res.Property, res.Message); return(View(sensorTypeViewModel)); } }
// GET: SensorType/Edit/5 public async Task <ActionResult> Edit(int id) { var sensorTypeDto = await _sensorTypeManager.GetSensorTypeByIdAsync(id); if (sensorTypeDto != null) { EditSensorTypeViewModel sensorTypeViewModel = _mapper.Map <SensorTypeDto, EditSensorTypeViewModel>(sensorTypeDto); return(ViewComponent("SensorTypeEdit", sensorTypeViewModel)); } return(ViewComponent("SensorTypeEdit", null)); }
public IViewComponentResult Invoke(EditSensorTypeViewModel model) => View(model);