public async Task <IActionResult> Edit(EditDashboardViewModel model) { if (!ModelState.IsValid) { return(View(model)); } DashboardDto dashboardDto = _mapper.Map <EditDashboardViewModel, DashboardDto>(model); IconDto iconDto = null; if (model.IconFile != null) { dashboardDto.IconId = await _iconManager.CreateAndGetIconId(model.IconFile); iconDto = await _iconManager.GetById(dashboardDto.IconId.GetValueOrDefault()); dashboardDto.IconPath = iconDto.Path; } dashboardDto.AppUserId = _userManager.GetUserId(User); var res = _dashboardManager.Update(dashboardDto).Result; if (res != null) { res = _dashboardManager.GetById(res.Id).Result; DashboardViewModel dashmodel = _mapper.Map <DashboardDto, DashboardViewModel>(res); if (model.IconFile == null) { iconDto = await _iconManager.GetById(dashboardDto.IconId.GetValueOrDefault()); dashboardDto.IconPath = iconDto.Path; } if (!dashmodel.IsPublic) { dashmodel.DashCreatorUserName = User.Claims.ElementAt(1).Value; } return(ViewComponent("DashboardElement", dashmodel)); } else { //ModelState.AddModelError(res.Property, res.Message); return(View(model)); } }