public ActionResult EditKitType(string id, string newName, string newWeight, string oldName, string oldWeight) { EVRPModContext db = new EVRPModContext(); string Result = ""; if (newName == "" || newWeight == "") { Result = "Ошибка. Не все поля заполнены"; } //if (oldName == newName && oldWeight == newWeight) //{ //} float Weight = 0; if (Result == "") { try { Weight = string.IsNullOrEmpty(newWeight) ? 0 : float.Parse(newWeight.Replace(".", ",")); if (Weight <= 0) { Result = "Ошибка. Вес комплекта должен быть больше нуля"; } } catch { return(Json("Ошибка. Введено нечисловое значение")); } } if (Result == "") { //var Obj = db.kitType.FirstOrDefault(x => x.name == newName && x.weight == newWeight); //if (Obj != null) //{ // Result = "Данный комплект уже присутствует в списке"; // return Json(Result); //} //else try { var ObjEdit = db.kitType.FirstOrDefault(x => x.id == Convert.ToInt32(id)); ObjEdit.name = newName; ObjEdit.weight = Weight; db.SaveChanges(); Result = "Данные изменены"; } catch { return(Json("Ошибка. Введено нечисловое значение")); } } return(Json(Result)); }
public ActionResult GetAddressList() { EVRPModContext db = new EVRPModContext(); var DepotData = db.depotData.OrderBy(x => x.orderAddress).ToList(); var CustomerData = db.customerData.OrderBy(x => x.orderAddress).ToList(); List <string> Address = new List <string>(); int orderAddress = -1; foreach (var itemCustomerData in CustomerData) { if (itemCustomerData.orderAddress != orderAddress) { Address.Add(itemCustomerData.address); //orderAddress = (int) itemCustomerData.orderAddress; } } foreach (var itemDepotData in DepotData) { Address.Add(itemDepotData.address); } return(Json(Address)); }
public ActionResult AddCustomerData(int kitType, string latitude, string longitude, int count, string address) { EVRPModContext db = new EVRPModContext(); string Result = ""; //var Obj = db.customerData.FirstOrDefault(x => x.kitType == kitType && x.latitude == latitude && x.longitude == longitude && x.count == count); if (latitude == "" || latitude == "") { Result = "Ошибка. Не все поля заполнены"; } //if (Obj != null) //{ // Result = "Данный заказ уже имеется в списке"; // return Json(Result); //} //else //{ if (Result == "") { if (count < 1) { Result = "Ошибка. Количество должно быть целым положительным числом"; } else if (db.kitType.FirstOrDefault(x => x.id == kitType) == null) { Result = "Ошибка. Указанный тип комплекта не существует"; } else { var newObj = new customerData { //id = (db.vehicleData.Max(x=>x.id)!=null? db.vehicleData.Max(x => x.id)+1:1), kitType = kitType, latitude = latitude, longitude = longitude, count = count, address = address, }; db.customerData.Add(newObj); //db.SaveChanges(); Result = "Новый заказ добавлен"; AdditionalVariablesAndFunctions.ArrangementOfAddresses(); db.AlgorithmSettings.Where(x => x.variable == "RoadAccountingTablesAreSaved").FirstOrDefault().state = false; db.SaveChanges(); } } return(Json(Result)); //} }
public ActionResult GetDepotData() { EVRPModContext db = new EVRPModContext(); var Obj = db.depotData.ToList(); return(Json(Obj)); }
public ActionResult GetKitType() { EVRPModContext db = new EVRPModContext(); var Obj = db.kitType.ToList(); return(Json(Obj)); }
public ActionResult GetKitTypeForId(string id) { EVRPModContext db = new EVRPModContext(); var Obj = db.kitType.FirstOrDefault(x => x.id == Convert.ToInt32(id)); return(Json(Obj)); }
public ActionResult GetVehiceData() { EVRPModContext db = new EVRPModContext(); var Obj = db.vehicleData.ToList(); return(Json(Obj)); }
public ActionResult GetVehiceDataForId(string id) { EVRPModContext db = new EVRPModContext(); var Obj = db.vehicleData.FirstOrDefault(x => x.id == Convert.ToInt32(id)); return(Json(Obj)); }
public ActionResult GetCustomerData() { EVRPModContext db = new EVRPModContext(); var Obj = db.customerData.ToList(); return(Json(Obj)); }
public static void SetPropertyValues() { EVRPModContext db = new EVRPModContext(); var ParametersKiniRayfaMethods = db.parametersKiniRayfaMethods.ToList(); var AverageSpeed = ParametersKiniRayfaMethods.Where(x => x.Criterion == "AverageSpeed").First(); var RoadQuality = ParametersKiniRayfaMethods.Where(x => x.Criterion == "RoadQuality").First(); var AverageRoadIntensity = ParametersKiniRayfaMethods.Where(x => x.Criterion == "AverageRoadIntensity").First(); speedRestriction.xmax = (int)AverageSpeed.HighestValue; speedRestriction.xavg075 = (int)AverageSpeed.AverageValueFor__Values75; speedRestriction.xavg05 = (int)AverageSpeed.AverageValueFor__Values50; speedRestriction.xavg025 = (int)AverageSpeed.AverageValueFor__Values25; speedRestriction.xmin = (int)AverageSpeed.SmallestValue; speedRestriction.ymax = 1; speedRestriction.yaverage075 = 0.75; speedRestriction.yaverage05 = 0.5; speedRestriction.yaverage025 = 0.25; speedRestriction.ymin = 0; speedRestriction.rating = (int)AverageSpeed.Rating; speedRestriction.avgWeightCriteria = (int)AverageSpeed.ValueFor__WeightComparison__Criteria; roadQuality.xmax = (int)RoadQuality.HighestValue; roadQuality.xavg075 = (int)RoadQuality.AverageValueFor__Values75; roadQuality.xavg05 = (int)RoadQuality.AverageValueFor__Values50; roadQuality.xavg025 = (int)RoadQuality.AverageValueFor__Values25; roadQuality.xmin = (int)RoadQuality.SmallestValue; roadQuality.ymax = 1; roadQuality.yaverage075 = 0.75; roadQuality.yaverage05 = 0.5; roadQuality.yaverage025 = 0.25; roadQuality.ymin = 0; roadQuality.rating = (int)RoadQuality.Rating; roadQuality.avgWeightCriteria = (int)RoadQuality.ValueFor__WeightComparison__Criteria; avgPatency.xmax = (int)AverageRoadIntensity.HighestValue; avgPatency.xavg075 = (int)AverageRoadIntensity.AverageValueFor__Values75; avgPatency.xavg05 = (int)AverageRoadIntensity.AverageValueFor__Values50; avgPatency.xavg025 = (int)AverageRoadIntensity.AverageValueFor__Values25; avgPatency.xmin = (int)AverageRoadIntensity.SmallestValue; avgPatency.ymax = 0; avgPatency.yaverage075 = 0.25; avgPatency.yaverage05 = 0.5; avgPatency.yaverage025 = 0.75; avgPatency.ymin = 1; avgPatency.rating = (int)AverageRoadIntensity.Rating; avgPatency.avgWeightCriteria = (int)AverageRoadIntensity.ValueFor__WeightComparison__Criteria; }
public ActionResult GetTables() { EVRPModContext db = new EVRPModContext(); var AverageSpeedData = db.AverageSpeedTable.ToList(); var AverageRoadIntensityData = db.AverageRoadIntensityTable.ToList(); var RoadQualityData = db.RoadQualityTable.ToList(); var CostData = db.costTable.ToList(); if (AverageSpeedData.Any() && AverageRoadIntensityData.Any() && RoadQualityData.Any() && CostData.Any()) { int countAddress = (int)Math.Sqrt(AverageSpeedData.Count); double[][] AverageSpeedTable = new double[countAddress][]; double[][] AverageRoadIntensityTable = new double[countAddress][]; double[][] RoadQualityTable = new double[countAddress][]; double[][] CostTable = new double[countAddress][]; for (int i = 0; i < countAddress; i++) { AverageSpeedTable[i] = new double[countAddress]; AverageRoadIntensityTable[i] = new double[countAddress]; RoadQualityTable[i] = new double[countAddress]; CostTable[i] = new double[countAddress]; for (int j = 0; j < countAddress; j++) { AverageSpeedTable[i][j] = Math.Round(AverageSpeedData.Where(x => x.rowTable == i && x.columnTable == j).FirstOrDefault()?.valueTable ?? 0); AverageRoadIntensityTable[i][j] = Math.Round(AverageRoadIntensityData.Where(x => x.rowTable == i && x.columnTable == j).FirstOrDefault()?.valueTable ?? 0); RoadQualityTable[i][j] = Math.Round(RoadQualityData.Where(x => x.rowTable == i && x.columnTable == j).FirstOrDefault()?.valueTable ?? 0); CostTable[i][j] = Math.Round(CostData.Where(x => x.rowTable == i && x.columnTable == j).FirstOrDefault()?.valueTable ?? 0); } } RoadTable RoadTable = new RoadTable() { AverageSpeedTable = AverageSpeedTable, AverageRoadIntensityTable = AverageRoadIntensityTable, RoadQualityTable = RoadQualityTable, CostTable = CostTable }; //var DepotData = db.depotData.OrderBy(x => x.orderAddress).ToList(); //var CustomerData = db.customerData.OrderBy(x => x.orderAddress).ToList(); //List<string> Address = new List<string>(); //foreach (var itemCustomerData in CustomerData) //{ // Address.Add(itemCustomerData.address); //} //foreach (var itemDepotData in DepotData) //{ // Address.Add(itemDepotData.address); //} return(Json(RoadTable)); } return(Json(0)); }
public ActionResult AddVehicleInDepot(int depotId, int vehicleId, int count) { EVRPModContext db = new EVRPModContext(); var Obj = db.vehicleInDepot.FirstOrDefault(x => x.depotId == depotId && x.vehicleId == vehicleId && x.count == count); string Result; //if (Obj != null) //{ // Result = "Данное транспортное средство в депо уже имеется в списке"; //} //else if (db.depotData.FirstOrDefault(x => x.id == depotId) == null) { Result = "Ошибка. Указанное депо не существует"; } else if (db.vehicleData.FirstOrDefault(x => x.id == vehicleId) == null) { Result = "Ошибка. Указанное транспортное средство не существует"; } else if (count < 1) { Result = "Ошибка. Количество должно быть целым положительным числом"; } else { var newObj = new vehicleInDepot { //id = (db.vehicleData.Max(x=>x.id)!=null? db.vehicleData.Max(x => x.id)+1:1), depotId = depotId, vehicleId = vehicleId, count = count, }; db.vehicleInDepot.Add(newObj); db.SaveChanges(); Result = "Новое транспортное средство в депо добавлено"; //return Json(Result); } return(Json(Result)); }
public ActionResult AddDepotData(string name, string latitude, string longitude, string address) { EVRPModContext db = new EVRPModContext(); string Result = ""; if (name == "" || latitude == "" || longitude == "") { Result = "Ошибка. Не все поля заполнены"; } if (Result == "") { var Obj = db.depotData.FirstOrDefault(x => x.name == name && x.latitude == latitude && x.longitude == longitude); //string Result; if (Obj != null) { Result = "Данное депо уже имеется в списке"; return(Json(Result)); } else { var newObj = new depotData { //id = (db.vehicleData.Max(x=>x.id)!=null? db.vehicleData.Max(x => x.id)+1:1), name = name, latitude = latitude, longitude = longitude, address = address, }; db.depotData.Add(newObj); // db.SaveChanges(); Result = "Новое депо добавлено"; AdditionalVariablesAndFunctions.ArrangementOfAddresses(); // AdditionalVariablesAndFunctions.RoadAccountingTablesAreSaved = false; db.AlgorithmSettings.Where(x => x.variable == "RoadAccountingTablesAreSaved").FirstOrDefault().state = false; db.SaveChanges(); } } return(Json(Result)); }
public ActionResult EditVehicleInDepot(string id, int newDepotId, int newVehicleId, int newCount, int oldDepotId, int oldVehicleId, int oldCount) { EVRPModContext db = new EVRPModContext(); string Result; //if (oldDepotId == newDepotId && oldVehicleId == newVehicleId && oldCount == newCount) //{ //} //else if (db.depotData.FirstOrDefault(x => x.id == newDepotId) == null) { Result = "Ошибка. Указанное депо не существует"; } else if (db.vehicleData.FirstOrDefault(x => x.id == newVehicleId) == null) { Result = "Ошибка. Указанное транспортное средство не существует"; } else if (newCount < 1) { Result = "Ошибка. Количество должно быть целым положительным числом"; } else { //var Obj = db.vehicleInDepot.FirstOrDefault(x => x.vehicleId == newVehicleId && x.depotId == newDepotId && x.count == newCount); //if (Obj != null) //{ // Result = "Данное транспортное средство в депо уже присутствует в списке"; // //return Json(Result); //} //else //{ var ObjEdit = db.vehicleInDepot.FirstOrDefault(x => x.id == Convert.ToInt32(id)); ObjEdit.vehicleId = newVehicleId; ObjEdit.depotId = newDepotId; ObjEdit.count = newCount; db.SaveChanges(); Result = "Данные изменены"; //} } return(Json(Result)); }
public ActionResult DeleteVehiceData(string id) { EVRPModContext db = new EVRPModContext(); var Obj = db.vehicleData.FirstOrDefault(x => x.id == Convert.ToInt32(id)); if ((Obj != null)) { db.vehicleData.Remove(Obj); db.SaveChanges(); } var Result = "Транспортное средство удалено из списка"; return(Json(Result)); }
public ActionResult DeleteDepotData(string id) { EVRPModContext db = new EVRPModContext(); var Obj = db.depotData.FirstOrDefault(x => x.id == Convert.ToInt32(id)); if ((Obj != null)) { db.depotData.Remove(Obj); db.SaveChanges(); } var Result = "Депо удалено из списка"; return(Json(Result)); }
public ActionResult DeleteKitType(string id) { EVRPModContext db = new EVRPModContext(); var Obj = db.kitType.FirstOrDefault(x => x.id == Convert.ToInt32(id)); if ((Obj != null)) { db.kitType.Remove(Obj); db.SaveChanges(); } var Result = "Комплект удален из списка"; return(Json(Result)); }
public ActionResult EditCustomerData(string id, int newKitType, string newLatitude, string newLongitude, int newCount, int oldKitType, string oldLatitude, string oldLongitude, int oldCount, string address) { EVRPModContext db = new EVRPModContext(); string Result; if (newLatitude == "" || newLongitude == "") { Result = "Ошибка. Не все поля заполнены"; } if (newCount < 1) { Result = "Ошибка. Количество должно быть целым положительным числом"; } else if (db.kitType.FirstOrDefault(x => x.id == newKitType) == null) { Result = "Ошибка. Указанный тип комплекта не существует"; } else { //var Obj = db.customerData.FirstOrDefault(x => x.kitType == newKitType && x.latitude == newLatitude && x.longitude == newLongitude && x.count == newCount); //if (Obj != null) //{ // Result = "Данный заказ уже присутствует в списке"; // return Json(Result); //} //else //{ var ObjEdit = db.customerData.FirstOrDefault(x => x.id == Convert.ToInt32(id)); ObjEdit.kitType = newKitType; ObjEdit.latitude = newLatitude; ObjEdit.longitude = newLongitude; ObjEdit.count = newCount; ObjEdit.address = address; db.SaveChanges(); Result = "Данные изменены"; //} } return(Json(Result)); }
public ActionResult EditDepotData(string id, string newName, string newLatitude, string newLongitude, string oldName, string oldLatitude, string oldLongitude, string address) { EVRPModContext db = new EVRPModContext(); string Result = ""; if (newName == "" || newLatitude == "" || newLongitude == "") { Result = "Ошибка. Не все поля заполнены"; } if (Result == "") { if (oldName == newName && oldLatitude == newLatitude && oldLongitude == newLongitude) { } else { var Obj = db.depotData.FirstOrDefault(x => x.name == newName && x.latitude == newLatitude && x.longitude == newLongitude); if (Obj != null) { Result = "Данное депо уже присутствует в списке"; return(Json(Result)); } else { var ObjEdit = db.depotData.FirstOrDefault(x => x.id == Convert.ToInt32(id)); ObjEdit.name = newName; ObjEdit.latitude = newLatitude; ObjEdit.longitude = newLongitude; ObjEdit.address = address; db.SaveChanges(); Result = "Данные изменены"; } } } return(Json(Result)); }
public static void ArrangementOfAddresses() { EVRPModContext db = new EVRPModContext(); var DepotData = db.depotData.ToList(); var CustomerData = db.customerData.ToList(); //обнуляем порядок for (int i = 0; i < CustomerData.Count; i++) { CustomerData[i].orderAddress = -1; } for (int i = 0; i < DepotData.Count; i++) { DepotData[i].orderAddress = -1; } int orderAddress = 0; //устанавливаем порядок for (int i = 0; i < CustomerData.Count; i++) { if (CustomerData[i].orderAddress == -1) { //CustomerData[i].orderAddress = orderAddress; CustomerData.Where(x => x.latitude == CustomerData[i].latitude && x.longitude == CustomerData[i].longitude).ForEach(x => x.orderAddress = orderAddress); orderAddress++; } } for (int i = 0; i < DepotData.Count; i++) { DepotData[i].orderAddress = orderAddress; orderAddress++; } db.SaveChanges(); }
public ActionResult AddVehiceData(string Name, string Capacity, string ServiceCost, string CostRoads) { string Result = ""; EVRPModContext db = new EVRPModContext(); if (Name == "" || Capacity == "" || ServiceCost == "" || CostRoads == "") { Result = "Ошибка. Не все поля заполнены"; } //var Obj = db.vehicleData.FirstOrDefault(x => x.name == Name && x.capacity == Capacity && x.serviceCost == ServiceCost && x.costRoads == CostRoads); //if (Obj != null) //{ // Result = "Данное транспортное средство уже имеется в списке"; // return Json(Result); //} float capacity = 0; float serviceCost = 0; float costRoads = 0; if (Result == "") { try { capacity = string.IsNullOrEmpty(Capacity) ? 0 : float.Parse(Capacity.Replace(".", ",")); serviceCost = string.IsNullOrEmpty(ServiceCost) ? 0 : float.Parse(ServiceCost.Replace(".", ",")); costRoads = string.IsNullOrEmpty(CostRoads) ? 0 : float.Parse(CostRoads.Replace(".", ",")); if (Result == "") { if (capacity <= 0) { Result = "Ошибка. Грузоподъемность должна быть больше нуля"; } } if (Result == "") { if (serviceCost <= 0) { Result = "Ошибка. Обслуживание должно быть больше нуля"; } } if (Result == "") { if (serviceCost <= 0) { Result = "Ошибка. Стоимость платных дорог должна быть больше нуля"; } } } catch { return(Json("Ошибка. Введено нечисловое значение")); } } if (Result == "") { try { var newObj = new vehicleData { //id = (db.vehicleData.Max(x=>x.id)!=null? db.vehicleData.Max(x => x.id)+1:1), name = Name, //capacity = string.IsNullOrEmpty(Capacity) ? 0 : float.Parse(Capacity.Replace(".", ",")), //serviceCost = string.IsNullOrEmpty(ServiceCost) ? 0 : float.Parse(ServiceCost.Replace(".", ",")), //costRoads = string.IsNullOrEmpty(CostRoads) ? 0 : float.Parse(CostRoads.Replace(".", ",")), capacity = capacity, serviceCost = serviceCost, costRoads = costRoads }; db.vehicleData.Add(newObj); db.SaveChanges(); return(Json("Новое транспортное средство добавлено")); } catch { return(Json("Ошибка. Введено нечисловое значение")); } } return(Json(Result)); }
public ActionResult EditVehiceData(string id, string newName, string newCapacity, string newServiceCost, string newCostRoads, string oldName, string oldCapacity, string oldServiceCost, string oldCostRoads) { EVRPModContext db = new EVRPModContext(); string Result = ""; if (newName == "" || newCapacity == "" || newServiceCost == "" || newCostRoads == "") { Result = "Ошибка. Не все поля заполнены"; } //if (oldName == newName && oldCapacity == newCapacity && oldServiceCost == newServiceCost && oldCostRoads == newCostRoads) //{ //} float capacity = 0; float serviceCost = 0; float costRoads = 0; if (Result == "") { try { capacity = string.IsNullOrEmpty(newCapacity) ? 0 : float.Parse(newCapacity.Replace(".", ",")); serviceCost = string.IsNullOrEmpty(newServiceCost) ? 0 : float.Parse(newServiceCost.Replace(".", ",")); costRoads = string.IsNullOrEmpty(newCostRoads) ? 0 : float.Parse(newCostRoads.Replace(".", ",")); if (Result == "") { if (capacity <= 0) { Result = "Ошибка. Грузоподъемность должна быть больше нуля"; } } if (Result == "") { if (serviceCost <= 0) { Result = "Ошибка. Обслуживание должно быть больше нуля"; } } if (Result == "") { if (serviceCost <= 0) { Result = "Ошибка. Стоимость платных дорог должна быть больше нуля"; } } } catch { return(Json("Ошибка. Введено нечисловое значение")); } } if (Result == "") { //var Obj = db.vehicleData.FirstOrDefault(x => x.name == newName && x.capacity == newCapacity && x.serviceCost == newServiceCost && x.costRoads == newCostRoads); //if (Obj != null) //{ // Result = "Данное транспортное средство уже присутствует в списке"; // return Json(Result); //} //else try { var ObjEdit = db.vehicleData.FirstOrDefault(x => x.id == Convert.ToInt32(id)); ObjEdit.name = newName; ObjEdit.capacity = capacity; ObjEdit.serviceCost = serviceCost; ObjEdit.costRoads = costRoads; db.SaveChanges(); Result = "Данные изменены"; } catch { return(Json("Ошибка. Введено нечисловое значение")); } } return(Json(Result)); }
public ActionResult AddKitType(string name, string weight) { string Result = ""; EVRPModContext db = new EVRPModContext(); if (name == "" || weight == "") { Result = "Ошибка. Не все поля заполнены"; } //var Obj = db.kitType.FirstOrDefault(x => x.name == name && x.weight == weight); //if (Obj != null) //{ // Result = "Данный комплект уже имеется в списке"; // return Json(Result); //} float Weight = 0; if (Result == "") { try { Weight = string.IsNullOrEmpty(weight) ? 0 : float.Parse(weight.Replace(".", ",")); if (Weight <= 0) { Result = "Ошибка. Вес комплекта должен быть больше нуля"; } } catch { return(Json("Ошибка. Введено нечисловое значение")); } } if (Result == "") { try { var newObj = new kitType { //id = (db.vehicleData.Max(x=>x.id)!=null? db.vehicleData.Max(x => x.id)+1:1), name = name, weight = Weight, }; db.kitType.Add(newObj); db.SaveChanges(); Result = "Новый комплект добавлен"; return(Json(Result)); } catch { return(Json("Ошибка. Введено нечисловое значение")); } } return(Json(Result)); }
public ActionResult SaveTables(string[][] AverageSpeedTable, string[][] AverageRoadIntensityTable, string[][] RoadQualityTable, string[][] CostTable) { //AdditionalVariablesAndFunctions.ArrangementOfAddresses(); //AdditionalVariablesAndFunctions.RoadAccountingTablesAreSaved = true; EVRPModContext db = new EVRPModContext(); var AverageSpeedData = db.AverageSpeedTable.ToList(); var AverageRoadIntensityData = db.AverageRoadIntensityTable.ToList(); var RoadQualityData = db.RoadQualityTable.ToList(); var CostData = db.costTable.ToList(); db.AverageSpeedTable.RemoveRange(db.AverageSpeedTable.ToList()); db.AverageRoadIntensityTable.RemoveRange(db.AverageRoadIntensityTable.ToList()); db.RoadQualityTable.RemoveRange(db.RoadQualityTable.ToList()); db.costTable.RemoveRange(db.costTable.ToList()); int countTable = AverageSpeedTable.Length; int id = 0; float valueTableAverageSpeedTable; float valueTableAverageRoadIntensityTable; float valueTableRoadQualityTable; float valueTableCostTable; //float value = 0.000f; try { for (int i = 0; i < countTable; i++) { for (int j = 0; j < countTable; j++) { valueTableAverageSpeedTable = string.IsNullOrEmpty(AverageSpeedTable[i][j]) ? 0 : float.Parse(AverageSpeedTable[i][j].Replace(".", ",")); valueTableAverageRoadIntensityTable = string.IsNullOrEmpty(AverageRoadIntensityTable[i][j]) ? 0 : float.Parse(AverageRoadIntensityTable[i][j].Replace(".", ",")); valueTableRoadQualityTable = string.IsNullOrEmpty(RoadQualityTable[i][j]) ? 0 : float.Parse(RoadQualityTable[i][j].Replace(".", ",")); valueTableCostTable = string.IsNullOrEmpty(CostTable[i][j]) ? 0 : float.Parse(CostTable[i][j].Replace(".", ",")); if (valueTableAverageSpeedTable < 20 && valueTableAverageSpeedTable != 0 || valueTableAverageSpeedTable > 110 && valueTableAverageSpeedTable != 0) { return(Json("Ошибка. Значения средней скорости выходят за пределы")); } else if (valueTableRoadQualityTable < 1 && valueTableRoadQualityTable != 0 || valueTableRoadQualityTable > 10 && valueTableRoadQualityTable != 0) { return(Json("Ошибка. Значения среднего качества дорог выходят за пределы")); } else if (valueTableAverageRoadIntensityTable < 200 && valueTableAverageRoadIntensityTable != 0 || valueTableAverageRoadIntensityTable > 14000 && valueTableAverageRoadIntensityTable != 0) { return(Json("Ошибка. Значения интенсивности движения выходят за пределы")); } else if (valueTableCostTable < 0) { return(Json("Ошибка. Значения протяженности платных дорог не должны быть ниже нуля")); } var newObjAverageSpeedTable = new AverageSpeedTable { id = id, rowTable = i, columnTable = j, valueTable = valueTableAverageSpeedTable //valueTable = float.TryParse(AverageSpeedTable[i][j].Replace(".", ","), out value) ? 0 : float.Parse(AverageSpeedTable[i][j].Replace(".", ",")) //valueTable = Convert.ToDouble(string.IsNullOrEmpty(AverageSpeedTable[i][j]) ? "0" : (double) AverageSpeedTable[i][j]) }; var newObjAverageRoadIntensityTable = new AverageRoadIntensityTable { id = id, rowTable = i, columnTable = j, valueTable = valueTableAverageRoadIntensityTable //valueTable = Convert.ToInt32(string.IsNullOrEmpty(AverageRoadIntensityTable[i][j]) ? "0" : AverageRoadIntensityTable[i][j]) }; var newObjRoadQualityTable = new RoadQualityTable { id = id, rowTable = i, columnTable = j, valueTable = valueTableRoadQualityTable //valueTable = Convert.ToInt32(string.IsNullOrEmpty(RoadQualityTable[i][j]) ? "0" : RoadQualityTable[i][j]) }; var newObjCostTable = new costTable { id = id, rowTable = i, columnTable = j, valueTable = valueTableCostTable //valueTable = Convert.ToInt32(string.IsNullOrEmpty(CostTable[i][j]) ? "0" : CostTable[i][j]) }; db.AverageSpeedTable.Add(newObjAverageSpeedTable); db.AverageRoadIntensityTable.Add(newObjAverageRoadIntensityTable); db.RoadQualityTable.Add(newObjRoadQualityTable); db.costTable.Add(newObjCostTable); id++; } } //var newObj = new depotData //{ // //id = (db.vehicleData.Max(x=>x.id)!=null? db.vehicleData.Max(x => x.id)+1:1), // name = name, // latitude = latitude, // longitude = longitude, // address = address, //}; //db.depotData.Add(newObj); db.AlgorithmSettings.Where(x => x.variable == "RoadAccountingTablesAreSaved").FirstOrDefault().state = true; db.SaveChanges(); return(Json(0)); } catch { return(Json("Ошибка. Введено нечисловое значение")); } }