Пример #1
0
        public async Task <ActionResult> Edit(int id)
        {
            var toastDto = await _toastManager.GetById(id);

            CreateToastViewModel toastViewModel = _mapper.Map <ToastDto, CreateToastViewModel>(toastDto);

            return(View("Edit", toastViewModel));
        }
Пример #2
0
        public ActionResult Create(int sensorId)
        {
            CreateToastViewModel model = new CreateToastViewModel
            {
                SensorId = sensorId
            };

            return(View(model));
        }
Пример #3
0
        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());
            }
        }
Пример #4
0
        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());
            }
        }