public void Create_Scenario(Create_Scenario cmd) { var scenarioDto = cmd.Scenario; var destinationIds = scenarioDto.Deliveries.Select(o => o.Known_Destination_Id); var destinations = DocumentSession.Advanced.LuceneQuery<Destination>().WhereIn("Id", destinationIds).ToList(); //foreach (var order in scenarioDto.Deliveries) //{ // if (order.DestinationExternalId.IsNullOrEmpty()) // continue; // var destination = new Destination // { // Id = order.Known_Destination_Id, // Name = "None", // ExternalId = order.DestinationExternalId, // UserId = scenarioDto.UserId, // Location = new Location(order.Latitude, order.Longitude), // Address = Address.Parse(order.Address), // }; // //DocumentSession.Store(destination); // destinations.Add(destination); //} var scenario = new Scenario { //Id = scenarioDto.Id, UserId = scenarioDto.UserId, Created = DateTime.Now, Date = scenarioDto.Date, Name = scenarioDto.Name, Deliveries = scenarioDto.Deliveries.Select(o => new Delivery { ExternalId = o.ExternalId, Known_Destination = destinations.Where(d => d.Id == o.Known_Destination_Id).DefaultIfEmpty(Destination.Empty).SingleOrDefault(), Volume = new Quantity(o.Volume, new Unit(o.Volume_Unit)), Weight = new Quantity(o.Weight, new Unit(o.Weight_Unit)), Location = new Location(o.Latitude, o.Longitude), Address = Address.Parse(o.Address), }).ToList(), Distances = scenarioDto.Distances.Select(d => new Distance { From = new Location(d.From_Latitide, d.From_Longitude), To = new Location(d.To_Latitide, d.To_Longitude), Km = d.Km, Time = TimeSpan.FromSeconds(d.TimeInSeconds) }).ToList(), }; DocumentSession.Store(scenario); DocumentSession.SaveChanges(); }
public void Insert_New_Scenario() { var container = Container.Init_Container(); var service = container.Resolve<ScenarioService>(); var cmd = new Create_Scenario { }; service.Create_Scenario(cmd); }
public void Test_Algorithm_Random() { var container = Container.Init_Container().Configure_Raven_For_Testing(); var service = container.Resolve<ScenarioService>(); var documentStore = container.Resolve<IDocumentSession>(); var cmd = new Create_Scenario { Scenario = Test_Helper.Build_Random_Scenario() }; service.Create_Scenario(cmd); var scenario = documentStore.Query<Routing.Domain.Aggregates.Scenario>().First(); service.Execute_Simulation(new Execute_Simulation { Algorithm = Algorithm.Random, ScenarioId = scenario.Id }); }
//[PrincipalPermission(SecurityAction.Demand)] public void Create_Scenario(Create_Scenario command) { Service.Create_Scenario(command); }
public ActionResult Create_Scenario(Create_Scenario cmd) { return View(); }