/// <summary> /// Добавление расстояний между зонами /// </summary> private static void AddRoutes() { using (var db = new TransportContext()) { while (true) { Console.Write("***Введите идентификатор начальной зоны: "); var input = Console.ReadLine(); int originId; if (Int32.TryParse(input, out originId) && originId != 0) { var origin = db.Areas.Find(originId); if (origin == null) continue; Console.WriteLine($"Введите построчно идентификатор зоны и расстояние до нее от {origin.Name} (enter - закончить)"); do { input = Console.ReadLine(); var destIdDist = input.Split(new[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries); if (destIdDist.Length == 2) { int destId; int distance; if (Int32.TryParse(destIdDist[0], out destId) && Int32.TryParse(destIdDist[1], out distance) && originId != destId) { var dest = db.Areas.Find(destId); var areaRoute = new AreaRoutes { OriginId = originId, DestinationId = destId, Distance = distance }; db.AreaRoutes.Add(areaRoute); try { db.SaveChanges(); Console.WriteLine($"Путь от {origin.Name} до {dest.Name} равный {distance} сохранен"); } catch (DbUpdateException e) { db.AreaRoutes.Remove(areaRoute); Console.WriteLine("Дублирование записи, повторите ввод"); } } else { Console.WriteLine("Ошибка ввода"); } } } while (input != String.Empty); } else break; } } }
public static IMvcBuilder ConfigureRazorPages(this IServiceCollection services) => services.AddRazorPages(options => { options.Conventions.AllowAnonymousToAreaFolder(AreaRoutes.AuthArea, AreaRoutes.Route(AreaRoutes.AuthArea)); options.Conventions.AllowAnonymousToAreaFolder(AreaRoutes.OffersArea, AreaRoutes.Route(AreaRoutes.OffersArea)); options.Conventions.AllowAnonymousToAreaFolder(AreaRoutes.CartArea, AreaRoutes.Route(AreaRoutes.CartArea)); options.Conventions.AuthorizeAreaFolder(AreaRoutes.BookingsArea, AreaRoutes.Route(AreaRoutes.BookingsArea)); options.Conventions.AuthorizeAreaFolder(AreaRoutes.ProfileArea, AreaRoutes.Route(AreaRoutes.ProfileArea)); options.Conventions.AuthorizeAreaFolder(AreaRoutes.OrdersArea, AreaRoutes.Route(AreaRoutes.OrdersArea)); options.Conventions.AuthorizeAreaFolder(AreaRoutes.StatsArea, AreaRoutes.Route(AreaRoutes.StatsArea)); });