Beispiel #1
0
        public IActionResult MassEditing()
        {
            GetDeviceType devicetype = new GetDeviceType();

            ViewData["ChangeTypeId"] = new SelectList(devicetype.ListofDevices(), "Id", "Name");
            GetListOfDevices newdeviceList = new GetListOfDevices();
            var listing = newdeviceList.GetListofDevices();

            return(View(listing));
        }
Beispiel #2
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());
            }
        }