public ActionResult <Ingredient> Get(string name) { if (!_mealService.TryGetIngredient(name, out Domain.Ingredient ingredient)) { return(NotFound($"Ingredient with name \"{name}\" does not exist.")); } return(_dtoConverter.ToDto(ingredient)); }
public ActionResult <Meal> Get(int id, int?peopleToFeed) { if (!_mealService.TryGetMeal(id, out Domain.Meal meal)) { return(NotFound($"Meal with id \"{id}\" does not exist.")); } if (peopleToFeed.HasValue) { meal.ScaleTo(new Domain.Values.ServingSize(peopleToFeed.Value)); } return(_dtoConverter.ToDto(meal)); }
private void GenerateArrowGraphFromGraphCompilation() { lock (m_Lock) { ArrowGraphDto = null; IList <IDependentActivity <int> > dependentActivities = GraphCompilation.DependentActivities .Select(x => (IDependentActivity <int>)x.WorkingCopy()) .ToList(); if (!HasCompilationErrors && dependentActivities.Any()) { var arrowGraphCompiler = ArrowGraphCompiler <int, IDependentActivity <int> > .Create(); foreach (DependentActivity <int> dependentActivity in dependentActivities) { dependentActivity.Dependencies.UnionWith(dependentActivity.ResourceDependencies); dependentActivity.ResourceDependencies.Clear(); arrowGraphCompiler.AddActivity(dependentActivity); } arrowGraphCompiler.Compile(); Graph <int, IDependentActivity <int>, IEvent <int> > arrowGraph = arrowGraphCompiler.ToGraph(); if (arrowGraph == null) { throw new InvalidOperationException("Cannot construct arrow graph"); } ArrowGraphDto = DtoConverter.ToDto(arrowGraph); } GenerateArrowGraphDataFromDto(); } }
private ProjectPlanDto BuildProjectPlanDto() { lock (m_Lock) { return(new ProjectPlanDto() { ProjectStart = ProjectStart, DependentActivities = Activities.Select(x => DtoConverter.ToDto(x)).ToList(), ResourceSettings = ResourceSettingsDto.Copy(), ArrowGraphSettings = ArrowGraphSettingsDto.Copy(), GraphCompilation = DtoConverter.ToDto(GraphCompilation, CyclomaticComplexity.GetValueOrDefault(), Duration.GetValueOrDefault()), ArrowGraph = ArrowGraphDto != null?ArrowGraphDto.Copy() : new ArrowGraphDto() { Edges = new List <ActivityEdgeDto>(), Nodes = new List <EventNodeDto>(), IsStale = false }, HasStaleOutputs = HasStaleOutputs }); } }