public async Task <ActionResult> Edit(int id) { var toastDto = await _toastManager.GetById(id); CreateToastViewModel toastViewModel = _mapper.Map <ToastDto, CreateToastViewModel>(toastDto); return(View("Edit", toastViewModel)); }
public ActionResult Create(int sensorId) { CreateToastViewModel model = new CreateToastViewModel { SensorId = sensorId }; return(View(model)); }
public async Task <ActionResult> Edit(CreateToastViewModel toastViewModel) { ToastDto sensorTypeDto = _mapper.Map <CreateToastViewModel, ToastDto>(toastViewModel); var res = await _toastManager.Update(sensorTypeDto); if (res.Succeeded) { return(RedirectToAction("Index", "Toast", new { sensorId = toastViewModel.SensorId })); } else { return(View()); } }
public async Task <ActionResult> Create(CreateToastViewModel toastViewModel) { try { var toastDto = _mapper.Map <CreateToastViewModel, ToastDto>(toastViewModel); await _toastManager.Create(toastDto); return(RedirectToAction("Index", "Toast", new { sensorId = toastViewModel.SensorId })); } catch { return(View()); } }