public ActionResult <DeviceOutputModel> CreateDevice([FromBody] DeviceInputModel device) { var id = _testingCaseService.AddDevice(_mapper.Map <DeviceDto>(device)); //var result = _mapper.Map<DeviceOutputModel>(_testingCaseService.GetDeviceById(id)); return(Ok(id)); }
public ActionResult Add() { var viewModel = new DeviceInputModel(); viewModel.Categories = this.categories .GetAll() .Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }) .ToList(); return this.View(viewModel); }
public ActionResult Add(DeviceInputModel model) { if (this.ModelState.IsValid) { var deviceName = this.devices .GetAll() .FirstOrDefault(x => x.Name.ToLower() == model.Name.ToLower()); if (deviceName == null) { var newDevice = this.Mapper.Map<Device>(model); this.devices.Add(newDevice); TempData["Success"] = GlobalConstants.DeviceAddNotify; } else { TempData["Warning"] = GlobalConstants.DeviceExistsNotify; } return this.Redirect("/Admin/Devices/Index"); } return this.View(model); }