Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }