public JsonResult AddDeviceCode(int TypeOfDevice) { data.Configuration.ProxyCreationEnabled = false; var type = data.OderCode(TypeOfDevice).Single().Code; var TypeSymbol = data.DeviceTypes.Where(x => x.Id == TypeOfDevice).Single().TypeSymbol.Trim() + type.ToString().PadLeft(5, '0'); var charts = data.Devices.Where(x => x.DeviceCode == TypeSymbol).FirstOrDefault(); if (charts == null) { } else { type = data.OderCode(TypeOfDevice).Single().Code; TypeSymbol = data.DeviceTypes.Where(x => x.Id == TypeOfDevice).Single().TypeSymbol.Trim() + type.ToString().PadLeft(5, '0'); } return(Json(new { data = TypeSymbol, }, JsonRequestBehavior.AllowGet)); }