public async Task <IActionResult> CreateNewMethod(Models.Method method) { if (ModelState.IsValid) { method.CreatedBy = GetCurrentUserAsync().Result; method.CreatedDate = System.DateTime.Now; method.LastModifiedDate = System.DateTime.Now; method.Status = "Draft"; _context.Methods.Add(method); await _context.SaveChangesAsync(); } MainViewModel main = new MainViewModel(); main.SelectedMethod = method; var plan = _context.Organizations.Where(y => y.Id == GetCurrentUserAsync().Result.OrganizationId).Select(z => z.SelectedPlanId); var connectors = _context.PlanDataConnectors.Where(y => y.PlanId == plan.First()).Select(z => z.DataSourceConnectorId); var connectorIds = String.Join(',', connectors.ToArray()); ViewBag.AvailableDataConnectors = _context.DataSourceConnectors.Where(y => connectorIds.Contains(y.Id)).ToList(); main.AvailableDataSources = await _context.DataSources.Include(x => x.CreatedBy).Include(y => y.Type).Where(z => connectorIds.Contains(z.TypeId) && z.CreatedById == GetCurrentUserAsync().Result.Id).ToListAsync(); main.AvailableSampleDataSources = await _context.SampleDataSources.Include(x => x.CreatedBy).Include(y => y.Type).Where(z => connectorIds.Contains(z.TypeId) && z.CreatedById == GetCurrentUserAsync().Result.Id).ToListAsync(); main.SelectedDataSource = new DataSource(); main.SelectedMethod.LinkedDataSources = new List <MethodDataSource>(); return(PartialView("_SetDataSource", main)); }
public async Task <IActionResult> LinkDataSourceToMethod(MainViewModel main) { Models.Method method = _context.Methods.Include(x => x.LinkedDataSources).Where(sim => sim.Id == main.SelectedMethod.Id).First(); DataSource dataSource = _context.DataSources.Where(arg => arg.Uri == main.SelectedDataSourceName).First(); if (_context.MethodDataSources.Where(x => (x.Method.Id == method.Id) && (x.Datafile.Id == dataSource.Id)).Count() == 0) { _context.MethodDataSources.Add(new MethodDataSource { Method = method, Datafile = dataSource }); await _context.SaveChangesAsync(); } main.SelectedDataProcessingRule = new DataProcessingRule(); main.AvailableDataProcessingRules = _context.DataProcessingRule.ToList(); return(PartialView("~/Views/Main/_ApplyRules.cshtml", main)); }
/// <summary> /// API to compare two methods /// </summary> /// <param name="methodA">Method A</param> /// <param name="methodB">Methods B</param> /// <returns>Comparision report between these two methods</returns> public double Compare(Models.Method methodA, Models.Method methodB) { return(Recurse(methodA.MethodNode, methodB.MethodNode) == false ? 1.0 : 0.0); }