Exemplo n.º 1
0
        public async Task <IActionResult> Add(EditTesterParameter model)
        {
            if (ModelState.IsValid)
            {
                var newParameter = testerParametersRepository.Add(model);
                //_context.Update(newParameter);
                _context.TesterParameters.Add(newParameter);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Main), new { name = product.DeviceName });
                return(RedirectToAction("Details", new { name = newParameter.DeviceName, revision = newParameter.Revision }));
            }

            return(View(model));
        }
        public TesterParameter Add(EditTesterParameter model)
        {
            var newParameter = _context.TesterParameters.FirstOrDefault(x => x.Id == model.Id && x.Revision == model.Revision);
            //newParameter.Parameter = AddParameter(model.Type, newParameter.Parameter,
            //    model.ParameterName, model.ParameterValue);
            var parameter = AddParameter(model.Type, newParameter.Parameter,
                model.ParameterName, model.ParameterValue);

            TesterParameter testerParameter = new TesterParameter()
            {
                DeviceName = newParameter.DeviceName,
                Parameter = parameter,
                Revision = model.Revision + 1
            };

            return testerParameter;
        }
 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;
 }
Exemplo n.º 4
0
        public async Task <IActionResult> Delete(int id, TesterParameterCodeType type, string parameterName, int revision, string parameterValue)
        {
            var product = await _context.TesterParameters.FirstOrDefaultAsync(x => x.Id == id);

            if (product == null)
            {
                return(NotFound());
            }

            var model = new EditTesterParameter
            {
                Id             = id,
                Type           = type,
                ParameterName  = parameterName,
                ParameterValue = parameterValue, // GetParameter(type, product.Parameter, parameterName, index),
                Revision       = revision
                                                 //Index = index
            };

            ViewBag.DeviceName = product.DeviceName;
            return(View(model));
        }
Exemplo n.º 5
0
        public IActionResult Edit(int id, TesterParameterCodeType type, string parameterName, string parameterValue, int revision /*int index*/)
        {
            var product = _context.TesterParameters.Where(tp => tp.Id == id && tp.Revision == revision).FirstOrDefault();

            if (product == null)
            {
                return(NotFound());
            }

            var model = new EditTesterParameter
            {
                Id             = id,
                Type           = type,
                ParameterName  = parameterName,
                ParameterValue = parameterValue, // GetParameter(type, product.Parameter, parameterName, index),
                Revision       = revision
                                                 //Index = index
            };

            ViewBag.DeviceName = product.DeviceName;
            return(View(model));
        }
        public TesterParameter Edit(string oldParameterName, string oldParameterValue, EditTesterParameter model)
        {
            var product = _context.TesterParameters.FirstOrDefault(x => x.Id == model.Id && x.Revision == model.Revision);

            //product.Parameter = EditParameter(model.Type, product.Parameter,
            //                oldParameterName, oldParameterValue, model.ParameterName, 
            //                model.ParameterValue/*, model.Index*/);
            var parameter = EditParameter(model.Type, product.Parameter,
                            oldParameterName, oldParameterValue, model.ParameterName,
                            model.ParameterValue);
            TesterParameter testerParameter = new TesterParameter()
            {
                DeviceName = product.DeviceName,
                Parameter = parameter,
                Revision = model.Revision + 1
            };
            return testerParameter;
        }
Exemplo n.º 7
0
        public async Task <IActionResult> MassEditing(string ChangeTypeId, string param, string ParameterValue = "")
        {
            if (ChangeTypeId != null && param != null)
            {
                GetDeviceType          getDeviceType = new GetDeviceType();
                var                    listOfDevice  = getDeviceType.ListofDevices().Where(d => d.Id == Convert.ToInt32(ChangeTypeId)).FirstOrDefault().Name;
                List <TesterParameter> deviceList    = testerParametersRepository.Main(listOfDevice).ToList();
                List <TesterParameter> tp            = testerParametersRepository.Main(listOfDevice).ToList();
                List <TesterParameter> tpList        = new List <TesterParameter>();
                List <TesterParameter> finalList     = new List <TesterParameter>();

                string[] parentChild     = param.Split("|");
                string   parentParameter = parentChild[0];
                string   childParameter  = parentChild[1];

                foreach (var device in deviceList)
                {
                    //var nextRevision = _context.TesterParameters.FirstOrDefault(x => x.DeviceName.ToLower() == device.DeviceName.ToLower() && x.Revision == (device.Revision + 1));
                    var nextRevision = tp.FirstOrDefault(x => x.DeviceName.ToLower() == device.DeviceName.ToLower() && x.Revision == (device.Revision + 1));
                    if (nextRevision == null)
                    {
                        tpList.Add(device);
                    }
                }
                foreach (TesterParameter testerParameter in tpList)
                {
                    var xmlSerializer        = new XmlSerializer(typeof(TesterParameterCode));
                    var testerparametercodes = testerParameter.TesterParameterCode = (TesterParameterCode)xmlSerializer.Deserialize(new StringReader(testerParameter.Parameter));
                    if (parentParameter == "DeviceParameters")
                    {
                        if (testerparametercodes?.DeviceParameters?.Parameters != null)
                        {
                            foreach (var parameter in testerparametercodes?.DeviceParameters?.Parameters)
                            {
                                if (parameter.Name == childParameter && parameter.InnerText.ToLower() == ParameterValue.ToLower())
                                {
                                    finalList.Add(testerParameter);
                                }
                                else if (parameter.Name == childParameter && ParameterValue == null)
                                {
                                    finalList.Add(testerParameter);
                                }
                            }
                        }
                    }
                    else if (parentParameter == "FirmwareGates")
                    {
                        if (testerparametercodes?.FirmwareGates?.Parameters != null)
                        {
                            foreach (var parameter in testerparametercodes?.FirmwareGates?.Parameters)
                            {
                                if (parameter.Name == childParameter && parameter.InnerText.ToLower() == ParameterValue.ToLower())
                                {
                                    finalList.Add(testerParameter);
                                }
                                else if (parameter.Name == childParameter && ParameterValue == null)
                                {
                                    finalList.Add(testerParameter);
                                }
                            }
                        }
                    }
                    else if (parentParameter == "ModemIncludeList")
                    {
                        if (testerparametercodes?.ModemIncludeList?.Parameters != null)
                        {
                            foreach (var parameter in testerparametercodes?.ModemIncludeList?.Parameters)
                            {
                                if (parameter.Name == childParameter && parameter.InnerText.ToLower() == ParameterValue.ToLower())
                                {
                                    finalList.Add(testerParameter);
                                }
                                else if (parameter.Name == childParameter && ParameterValue == null)
                                {
                                    finalList.Add(testerParameter);
                                }
                            }
                        }
                    }
                    else if (parentParameter == "ModemExcludeList")
                    {
                        if (testerparametercodes?.ModemExcludeList?.Parameters != null)
                        {
                            foreach (var parameter in testerparametercodes?.ModemExcludeList?.Parameters)
                            {
                                if (parameter.Name == childParameter && parameter.InnerText.ToLower() == ParameterValue.ToLower())
                                {
                                    finalList.Add(testerParameter);
                                }
                                else if (parameter.Name == childParameter && ParameterValue == null)
                                {
                                    finalList.Add(testerParameter);
                                }
                            }
                        }
                    }
                }



                foreach (TesterParameter devices in tpList)
                {
                    EditTesterParameter editTesterParameter = new EditTesterParameter();
                    editTesterParameter.Id            = devices.Id;
                    editTesterParameter.ParameterName = childParameter;
                    editTesterParameter.Revision      = devices.Revision;
                    editTesterParameter.Type          = (TesterParameterCodeType)System.Enum.Parse(typeof(TesterParameterCodeType), parentParameter);

                    var product = testerParametersRepository.Edit(childParameter, string.Empty, editTesterParameter);

                    _context.TesterParameters.Add(product);
                    //await _context.SaveChangesAsync();
                }
                return(MassEditing());
            }
            else
            {
                ViewData["ErrorMessage"] = "Please make sure you have entered value in each of the field above.";
                return(MassEditing());
            }
        }
Exemplo n.º 8
0
        public IActionResult DeleteConfirmed(EditTesterParameter model)
        {
            var device = testerParametersRepository.Delete(model);

            return(RedirectToAction("Details", new { name = device.DeviceName, revision = device.Revision }));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Add(int id, TesterParameterCodeType type, int revision)
        {
            var product = _context.TesterParameters.Where(tp => tp.Id == id && tp.Revision == revision).FirstOrDefault();

            //var product = await _context.TesterParameters.FindAsync(id);
            if (product == null)
            {
                return(NotFound());
            }

            var model = new EditTesterParameter
            {
                Id       = id,
                Type     = type,
                Revision = revision
            };

            if (type == TesterParameterCodeType.DeviceParameters)
            {
                var dropDownListForDeviceParam = new List <SelectListItem>();
                dropDownListForDeviceParam.Add(new SelectListItem
                {
                    Text  = "Please Select",
                    Value = ""
                });
                foreach (DeviceParametersName paramName in Enum.GetValues(typeof(DeviceParametersName)))
                {
                    dropDownListForDeviceParam.Add(new SelectListItem
                    {
                        Text  = Enum.GetName(typeof(DeviceParametersName), paramName),
                        Value = paramName.ToString()
                    });
                }
                ViewBag.DeviceParameterName = dropDownListForDeviceParam;
            }
            else if (type == TesterParameterCodeType.FirmwareGates)
            {
                var dropDownListForFirmwareGates = new List <SelectListItem>();
                dropDownListForFirmwareGates.Add(new SelectListItem
                {
                    Text  = "Please Select",
                    Value = ""
                });
                foreach (FirmwareGatesName paramName in Enum.GetValues(typeof(FirmwareGatesName)))
                {
                    dropDownListForFirmwareGates.Add(new SelectListItem
                    {
                        Text  = Enum.GetName(typeof(FirmwareGatesName), paramName),
                        Value = paramName.ToString()
                    });
                }
                ViewBag.FirmwareGatesName = dropDownListForFirmwareGates;
            }
            else if (type == TesterParameterCodeType.ModemIncludeList)
            {
                var dropDownListForModemInclude = new List <SelectListItem>();
                dropDownListForModemInclude.Add(new SelectListItem
                {
                    Text  = "Please Select",
                    Value = ""
                });
                foreach (ModemIncludeList paramName in Enum.GetValues(typeof(ModemIncludeList)))
                {
                    dropDownListForModemInclude.Add(new SelectListItem
                    {
                        Text  = Enum.GetName(typeof(ModemIncludeList), paramName),
                        Value = paramName.ToString()
                    });
                }
                ViewBag.ModemIncludeList = dropDownListForModemInclude;
            }
            else
            {
                var dropDownListForModemExclude = new List <SelectListItem>();
                dropDownListForModemExclude.Add(new SelectListItem
                {
                    Text  = "Please Select",
                    Value = ""
                });
                foreach (ModemExcludeList paramName in Enum.GetValues(typeof(ModemExcludeList)))
                {
                    dropDownListForModemExclude.Add(new SelectListItem
                    {
                        Text  = Enum.GetName(typeof(ModemExcludeList), paramName),
                        Value = paramName.ToString()
                    });
                }
                ViewBag.ModemExcludeList = dropDownListForModemExclude;
            }
            ViewBag.DeviceName = product.DeviceName;
            return(View(model));
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Edit(string oldParameterName, string oldParameterValue, EditTesterParameter model)
        {
            if (ModelState.IsValid)
            {
                var product = testerParametersRepository.Edit(oldParameterName, oldParameterValue, model);

                _context.TesterParameters.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { name = product.DeviceName, revision = product.Revision }));
            }

            return(View(model));
        }