public async Task <IActionResult> Create(AddTesterParameter model) { if (ModelState.IsValid) { var isDeviceExists = _context.TesterParameters.Where(t => t.DeviceName.Equals(model.DeviceName)).Select(n => n.DeviceName).FirstOrDefault(); if (isDeviceExists != null) { ViewBag.DeviceAlreadyExists = "This device is already exists in the database"; return(View(model)); } else { var addedmodel = testerParametersRepository.Create(model); _context.TesterParameters.Add(addedmodel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details), new { name = addedmodel.DeviceName })); } } return(View(model)); }
public TesterParameter Delete(EditTesterParameter model) { var device = _context.TesterParameters.FirstOrDefault(x => x.Id == model.Id && x.Revision == model.Revision); if (device != null) { var parameter = RemoveParameter(model.Type, device.Parameter, model.ParameterName, model.ParameterValue); //device.Parameter = RemoveParameter(model.Type, device.Parameter, model.ParameterName, model.ParameterValue/*, model.Index*/); TesterParameter testerParameter = new TesterParameter() { DeviceName = device.DeviceName, Parameter = parameter, Revision = model.Revision + 1 }; _context.TesterParameters.Add(testerParameter); _context.SaveChangesAsync(); return testerParameter; } return device; }