public PlotDetailsViewModel(INavigation navigation, string selectedPlotID) { _navigation = navigation; _plot = new PLOT(); _plot.PLOTID = selectedPlotID; _plotRepository = new PlotRepository(); UpdatePlotCommand = new Command(async() => await UpdatePlot()); DeletePlotCommand = new Command(async() => await DeletePlot()); ListFMU = PickerService.ForestItems().OrderBy(c => c.NAME).ToList(); CommentsCommand = new Command(async() => await ShowComments()); ListSpecies = PickerService.SpeciesItems().OrderBy(c => c.NAME).ToList(); ListCanopyOrigin = PickerService.CanopyOriginItems().OrderBy(c => c.NAME).ToList(); ListCanopyStructure = PickerService.CanopyStructureItems().OrderBy(c => c.NAME).ToList(); ListMaturityClass = PickerService.MaturityClassItems().OrderBy(c => c.NAME).ToList(); ListMeasurementType = PickerService.MeasurementTypeItems().OrderBy(c => c.NAME).ToList(); ListNonStandardType = PickerService.NonStandardTypeItems().OrderBy(c => c.NAME).ToList(); ListAccessCondition = PickerService.AccessConditionItems().OrderBy(c => c.NAME).ToList(); StandInfoCommand = new Command(async() => await ShowStandInfo()); ForestHealthCommand = new Command(async() => await ShowForestHealth()); PlotCrewCommand = new Command(async() => await ShowPlotCrew()); PhotoCommand = new Command(async() => await ShowPhoto()); LocationCommand = new Command(async() => await DoLocation()); ValidateCommand = new Command(async() => await DoValidate()); ListGrowthPlot = PickerService.GrowthPlotItems().OrderBy(c => c.NAME).ToList(); ListGrowthPlotType = PickerService.GrowthPlotTypeItems().OrderBy(c => c.NAME).ToList(); FetchPlotDetails(); IsChanged = false; OnAppearingCommand = new Command(() => OnAppearing()); OnDisappearingCommand = new Command(() => OnDisappearing()); // ListPerson = FillPersonPicker().OrderBy(c => c.NAME).ToList(); ListPerson = PickerService.FillPersonPicker(_plotRepository.GetPersonList(_plot.PROJECTID)).OrderBy(c => c.NAME).ToList(); }
private async Task <ActionResult> ShowCheckInForm(Claim claim) { return(View("CheckIn", new CheckInClaimModel(claim, await GetCurrentUserAsync(), claim.Character == null ? null : await PlotRepository.GetPlotsForCharacter(claim.Character)))); }
private Plot ModifyPlot(PlotRepository plotRepo, CharacterRepository characterRepo, Plot plot) { var dbPlot = plotRepo.GetById(plot.Id); dbPlot.Name = plot.Name; dbPlot.Description = plot.Description; var charactersToRemove = dbPlot.Characters.Where(dbc => !plot.Characters.Any(c => dbc.Id == c.Id || dbc.Character.Id == c.Character.Id)).ToList(); foreach (var characterToRemove in charactersToRemove) { dbPlot.Characters.Remove(characterToRemove); } foreach (var characterInPlot in plot.Characters) { var dbCharacter = dbPlot.Characters.FirstOrDefault(c => (characterInPlot.Id != 0 && c.Id == characterInPlot.Id) || c.Character.Id == characterInPlot.Character.Id); if (dbCharacter == null) { dbCharacter = new CharacterInPlot { Character = characterRepo.GetById(characterInPlot.Character.Id) }; dbPlot.Characters.Add(dbCharacter); } dbCharacter.Description = characterInPlot.Description; } plot = plotRepo.Modify(dbPlot); return(plot); }
public async Task <ActionResult> ByGroup(int projectId, int characterGroupId, string export) { var characterGroup = await ProjectRepository.GetGroupAsync(projectId, characterGroupId); var groupIds = await GetChildrenGroupIds(projectId, characterGroupId); var characters = (await ProjectRepository.GetCharacterByGroups(projectId, groupIds)).Where(ch => ch.IsActive).ToList(); if (characterGroup == null) { return(HttpNotFound()); } var plots = await PlotRepository.GetPlotsWithTargets(projectId); var list = new CharacterListByGroupViewModel(CurrentUserId, characters, characterGroup); var exportType = GetExportTypeByName(export); if (exportType == null) { return(View("ByGroup", list)); } return(await ExportWithCustomFronend(list.Items, list.Title, exportType.Value, new CharacterListItemViewModelExporter(list.Fields, UriService), list.ProjectName)); }
public async Task <ActionResult> ByGroup(int projectId, int characterGroupId, string export) { var characterGroup = await ProjectRepository.GetGroupAsync(projectId, characterGroupId); var groupIds = await GetChildrenGroupIds(projectId, characterGroupId); var characters = (await ProjectRepository.GetCharacterByGroups(projectId, groupIds)).Where(ch => ch.IsActive).ToList(); if (characterGroup == null) { return(NotFound()); } var plots = await PlotRepository.GetPlotsWithTargets(projectId); var list = new CharacterListByGroupViewModel(CurrentUserId, characters, characterGroup); var exportType = ExportTypeNameParserHelper.ToExportType(export); if (exportType == null) { return(View("ByGroup", list)); } return(await Export(list, exportType)); }
public async Task MoveElement(int projectId, int plotElementId, int parentCharacterId, int direction) { var character = await LoadProjectSubEntityAsync <Character>(projectId, parentCharacterId); character.RequestMasterAccess(CurrentUserId, acl => acl.CanEditRoles); var plots = await PlotRepository.GetPlotsForCharacter(character); var voc = character.GetCharacterPlotContainer(plots); var element = plots.Single(p => p.PlotElementId == plotElementId); switch (direction) { case -1: voc.MoveUp(element); break; case 1: voc.MoveDown(element); break; default: throw new ArgumentException(nameof(direction)); } character.PlotElementOrderData = voc.GetStoredOrder(); await UnitOfWork.SaveChangesAsync(); }
public PlotMutation(PlotRepository plotRepo, CharacterRepository characterRepo) { Name = "PlotMutation"; Field <PlotGraphType>("addOrModifyPlot", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <PlotInputGraphType> > { Name = "plot", Description = "new or edited plot" } ), resolve: context => { var plot = context.GetArgument <Plot>("plot"); if (plot.Id == 0) { var dbPlot = plotRepo.Add(new Plot()); plot.Id = dbPlot.Id; plot = ModifyPlot(plotRepo, characterRepo, plot); } else { plot = ModifyPlot(plotRepo, characterRepo, plot); } return(plot); }) .AddQAPermissions(); }
private async Task <ActionResult> MasterCharacterList(int projectId, Func <Character, bool> predicate, string export, string title, Func <CharacterListItemViewModel, bool> viewModelPredicate) { var characters = (await ProjectRepository.GetCharacters(projectId)).Where(predicate).ToList(); var error = await AsMaster(characters, projectId); if (error != null) { return(error); } var plots = await PlotRepository.GetPlotsWithTargets(projectId); var project = await GetProjectFromList(projectId, characters); var list = new CharacterListViewModel(CurrentUserId, title, characters, plots, project, viewModelPredicate); var exportType = GetExportTypeByName(export); if (exportType == null) { return(View("Index", list)); } return(await ExportWithCustomFronend(list.Items, list.Title, exportType.Value, new CharacterListItemViewModelExporter(list.Fields, UriService), list.ProjectName)); }
public async Task <ActionResult> HandoutReport(int projectid) { var plotElements = await PlotRepository.GetActiveHandouts(projectid); var characters = (await ProjectRepository.GetCharacters(projectid)).Where(c => c.IsActive).ToList(); return(View(new HandoutReportViewModel(plotElements, characters))); }
public AddPlotViewModel(INavigation navigation) { _navigation = navigation; _plotValidator = new PlotValidator(); _plot = new PLOT(); _plotRepository = new PlotRepository(); AddCommand = new Command(async() => await AddPlot("")); ViewAllCommand = new Command(async() => await ShowList()); ListFMU = PickerService.ForestItems().OrderBy(c => c.NAME).ToList(); }
public async Task <ActionResult> CharacterList(int projectid, string characterIds) { var characters = await ProjectRepository.LoadCharactersWithGroups(projectid, characterIds.UnCompressIdList()); var plotElements = (await PlotRepository.GetPlotsWithTargetAndText(projectid)).SelectMany(p => p.Elements).ToArray(); var viewModel = characters.Select( c => new PrintCharacterViewModel(CurrentUserId, c, plotElements, UriService)).ToArray(); return(View(viewModel)); }
public async Task <ActionResult> Character(int projectid, int characterid) { var character = await CharacterRepository.GetCharacterWithGroups(projectid, characterid); var error = WithCharacter(character); if (error != null) { return(error); } return(View(new PrintCharacterViewModel(CurrentUserId, character, await PlotRepository.GetPlotsForCharacter(character), UriService))); }
public ForestHealthViewModel(INavigation navigation, PLOT _thisplot) { _navigation = navigation; _plot = new PLOT(); _plot = _thisplot; _plotRepository = new PlotRepository(); if (_plot.FORESTHEALTHDATE == System.DateTime.MinValue) { _plot.FORESTHEALTHDATE = System.DateTime.Now; } // ListPerson = FillPersonPicker().OrderBy(c => c.NAME).ToList(); ListPerson = PickerService.FillPersonPicker(_plotRepository.GetPersonList(_plot.PROJECTID)).OrderBy(c => c.NAME).ToList(); }
public AddPlotViewModel(INavigation navigation, string fk) { _navigation = navigation; _plotValidator = new PlotValidator(); _plot = new PLOT(); _plotRepository = new PlotRepository(); _selectedprojectid = fk; Utils util = new Utils(); //Do defaults _plot.VSNPLOTNAME = "VSN"; _plot.IsDeleted = "N"; _plot.DATUM = "NAD83"; _plot.PROJECTID = fk; _plot.ACCESSCONDITIONCODE = 1; _plot.PLOTOVERVIEWDATE = System.DateTime.Now; _plot.MEASUREYEAR = _plot.PLOTOVERVIEWDATE.Year; _plot.CANOPYSTRUCTURECODE1 = "S"; _plot.MATURITYCLASSCODE1 = "S"; _plot.MATURITYCLASSRATIONALE1 = "Dominant cohort has achieved crown closure"; _plot.FOLLOWUPREQUIRED = "N"; if (util.UseDefaultDeclination) { _plot.DECLINATION = util.DefaultDeclination; } AddCommand = new Command(async() => await AddPlot(_selectedprojectid)); ViewAllCommand = new Command(async() => await ShowList()); ListFMU = PickerService.ForestItems().OrderBy(c => c.NAME).ToList(); ListSpecies = PickerService.SpeciesItems().OrderBy(c => c.NAME).ToList(); ListMeasurementType = PickerService.MeasurementTypeItems().OrderBy(c => c.NAME).ToList(); ListNonStandardType = PickerService.NonStandardTypeItems().OrderBy(c => c.NAME).ToList(); // ListPerson = FillPersonPicker().OrderBy(c => c.NAME).ToList(); ListPerson = PickerService.FillPersonPicker(_plotRepository.GetPersonList(_selectedprojectid)).OrderBy(c => c.NAME).ToList(); ListGrowthPlot = PickerService.GrowthPlotItems().OrderBy(c => c.NAME).ToList(); ListGrowthPlotType = PickerService.GrowthPlotTypeItems().OrderBy(c => c.NAME).ToList(); ListAccessCondition = PickerService.AccessConditionItems().OrderBy(c => c.NAME).ToList(); CommentsCommand = new Command(async() => await ShowComments()); StandInfoCommand = new Command(async() => await ShowStandInfo()); ForestHealthCommand = new Command(async() => await ShowForestHealth()); PlotCrewCommand = new Command(async() => await ShowPlotCrew()); PhotoCommand = new Command(async() => await ShowPhoto()); OnAppearingCommand = new Command(() => OnAppearing()); OnDisappearingCommand = new Command(() => OnDisappearing()); LocationCommand = new Command(async() => await DoLocation()); }
public async Task <IActionResult> Character(int projectid, int characterid) { var character = await CharacterRepository.GetCharacterWithGroups(projectid, characterid); if (character == null) { return(NotFound()); } if (!character.HasAnyAccess(CurrentUserId)) { return(NoAccesToProjectView(character.Project)); } return(View(new PrintCharacterViewModel(CurrentUserId, character, await PlotRepository.GetPlotsForCharacter(character), UriService))); }
// public ICommand SearchCommand { get; private set; } // public bool IsPlotTypeB { get; private set; } public PlotListViewModel(INavigation navigation) { _navigation = navigation; _plotRepository = new PlotRepository(); _selectedprojectid = ""; AddCommand = new Command(async() => await ShowAdd()); DeleteAllCommand = new Command(async() => await DeleteAll()); ShowFilteredCommand = new Command <PLOT>(async(x) => await ShowTrees(x)); ShowSiteCommand = new Command <PLOT>(async(x) => await ShowSite(x)); ShowSmallTreeCommand = new Command <PLOT>(async(x) => await ShowSmallTree(x)); ShowSoilCommand = new Command <PLOT>(async(x) => await ShowSoil(x)); ShowVegetationCommand = new Command <PLOT>(async(x) => await ShowVegetation(x)); ShowDWDCommand = new Command <PLOT>(async(x) => await ShowDWD(x)); FetchPlots(); }
public PlotDetailsViewModel(INavigation navigation, string selectedPlotID) { _navigation = navigation; _plot = new PLOT(); _plot.PLOTID = selectedPlotID; _plotRepository = new PlotRepository(); UpdatePlotCommand = new Command(async() => await UpdatePlot()); DeletePlotCommand = new Command(async() => await DeletePlot()); ListFMU = PickerService.ForestItems().OrderBy(c => c.NAME).ToList(); CommentsCommand = new Command(async() => await ShowComments()); ListSpecies = PickerService.SpeciesItems().OrderBy(c => c.NAME).ToList(); ListCanopyOrigin = PickerService.CanopyOriginItems().OrderBy(c => c.NAME).ToList(); ListCanopyStructure = PickerService.CanopyStructureItems().OrderBy(c => c.NAME).ToList(); ListMaturityClass = PickerService.MaturityClassItems().OrderBy(c => c.NAME).ToList(); FetchPlotDetails(); }
public AddPlotViewModel(INavigation navigation, string fk) { _navigation = navigation; _plotValidator = new PlotValidator(); _plot = new PLOT(); _plotRepository = new PlotRepository(); _selectedprojectid = fk; AddCommand = new Command(async() => await AddPlot(_selectedprojectid)); ViewAllCommand = new Command(async() => await ShowList()); ListFMU = PickerService.ForestItems().OrderBy(c => c.NAME).ToList(); ListSpecies = PickerService.SpeciesItems().OrderBy(c => c.NAME).ToList(); ListCanopyOrigin = PickerService.CanopyOriginItems().OrderBy(c => c.NAME).ToList(); ListCanopyStructure = PickerService.CanopyStructureItems().OrderBy(c => c.NAME).ToList(); ListMaturityClass = PickerService.MaturityClassItems().OrderBy(c => c.NAME).ToList(); CommentsCommand = new Command(async() => await ShowComments()); }
public async Task CreatPlot_ReturnNewObjectId() { var dbInMemoryOption = new DbContextOptionsBuilder <AgrotutorContext>() .UseInMemoryDatabase("CreatPlotWithImages").Options; using (var context = new AgrotutorContext(dbInMemoryOption)) { var rep = new PlotRepository(context); IntializaPictureRepository(); var plotController = new PlotsController(rep, _pictureRepository); var res = await plotController.CreatePlot(_newPlotWithImages) as OkObjectResult; Assert.IsNotNull(res); Assert.IsInstanceOfType(res.Value, typeof(PlotDto)); Assert.IsTrue(((PlotDto)res.Value).Id > 0); } }
public PlotQuery(PlotRepository plotRepo, IUsersIdentityService accountService) { Name = "PlotQuery"; Field <ListGraphType <PlotGraphType> >("all", arguments: ConscienceArguments.PaginationsAndSortingArgument, resolve: context => plotRepo.GetAll() .ApplyPaginationAndOrderBy(context) .ToList().Where(p => !accountService.CurrentUser.UserName.Contains("-") || p.Characters.Any(c => c.Character.Hosts.Any(h => h.Host.Account.UserName.StartsWith(accountService.CurrentUser.UserName.Split('-').First())))) //TODO: Remove this line, only to send both runs pre game ); Field <PlotGraphType>("byId", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "id", Description = "plot id" } ), resolve: context => plotRepo.GetById(context.GetArgument <int>("id"))); }
public StandInfoViewModel(INavigation navigation, PLOT _thisplot) { _navigation = navigation; _plot = new PLOT(); _plot = _thisplot; _plotRepository = new PlotRepository(); if (_plot.STANDINFODATE == System.DateTime.MinValue) { _plot.STANDINFODATE = System.DateTime.Now; } // ListPerson = FillPersonPicker().OrderBy(c => c.NAME).ToList(); ListPerson = PickerService.FillPersonPicker(_plotRepository.GetPersonList(_plot.PROJECTID)).OrderBy(c => c.NAME).ToList(); ListCanopyOrigin = PickerService.CanopyOriginItems().OrderBy(c => c.NAME).ToList(); ListCanopyStructure = PickerService.CanopyStructureItems().OrderBy(c => c.NAME).ToList(); ListMaturityClass = PickerService.MaturityClassItems().OrderBy(c => c.NAME).ToList(); ListDisturbanceCode = PickerService.DisturbanceItems().OrderBy(c => c.NAME).ToList(); ListMaturityClassRationale = PickerService.MaturityClassRationaleItems().ToList(); OnAppearingCommand = new Command(() => OnAppearing()); OnDisappearingCommand = new Command(() => OnDisappearing()); }
// public ICommand SearchCommand { get; private set; } // public bool IsPlotTypeB { get; private set; } public PlotListViewModel(INavigation navigation, string selectedprojectid) { _plot = new PLOT(); _navigation = navigation; _plotRepository = new PlotRepository(); _selectedprojectid = selectedprojectid; AddCommand = new Command(async() => await ShowAdd(_selectedprojectid)); DeleteAllCommand = new Command(async() => await DeleteAll()); ShowFilteredCommand = new Command <PLOT>(async(x) => await ShowTrees(x)); ShowSiteCommand = new Command <PLOT>(async(x) => await ShowSite(x)); ShowSmallTreeCommand = new Command <PLOT>(async(x) => await ShowSmallTree(x)); ShowSmallTreeTallyCommand = new Command <PLOT>(async(x) => await ShowSmallTreeTally(x)); ShowSoilCommand = new Command <PLOT>(async(x) => await ShowSoil(x)); ShowPhotoCommand = new Command <PLOT>(async(x) => await ShowPhoto(x)); ShowVegetationCommand = new Command <PLOT>(async(x) => await ShowVegetation(x)); ShowVegetationCensusCommand = new Command <PLOT>(async(x) => await ShowVegetationCensus(x)); ShowDWDCommand = new Command <PLOT>(async(x) => await ShowDWD(x)); // SearchCommand = new Command<string>(async (text) => await Search(text)); FetchPlots(); }
public async Task Can_Retrieve_By_ID() { var dbInMemoryOption = new DbContextOptionsBuilder <AgrotutorContext>() .UseInMemoryDatabase("RetrieveList").Options; using (var context = new AgrotutorContext(dbInMemoryOption)) { if (!context.Plots.Any()) { var rep = new PlotRepository(context); var plotController = new PlotsController(rep, _pictureRepository); await plotController.CreatePlot(_newPlotWithImages); var resultOk = await plotController.GetPlotsById(1) as OkObjectResult; Assert.IsNotNull(resultOk); var result = resultOk.Value as PlotDto; Assert.IsNotNull(result); Assert.IsTrue(result.Id == 1); } } }
private async Task <IReadOnlyList <PlotElement> > ShowPlotsForCharacter(Character character) { return(character.GetOrderedPlots(await PlotRepository.GetPlotsForCharacter(character))); }
public PlotCrewViewModel(INavigation navigation, PLOT _thisplot) { try { _navigation = navigation; _plot = new PLOT(); _plot = _thisplot; _plotRepository = new PlotRepository(); Utils util = new Utils(); // DO DEFAULTS if (_plot.SMALLTREESHRUBDATE == System.DateTime.MinValue) { _plot.SMALLTREESHRUBDATE = System.DateTime.Now; } if (_plot.DEFORMITYDATE == System.DateTime.MinValue) { _plot.DEFORMITYDATE = System.DateTime.Now; } if (_plot.DOWNWOODYDEBRISDATE == System.DateTime.MinValue) { _plot.DOWNWOODYDEBRISDATE = System.DateTime.Now; } if (_plot.UNDERSTORYVEGETATIONDATE == System.DateTime.MinValue) { _plot.UNDERSTORYVEGETATIONDATE = System.DateTime.Now; } if (_plot.UNDERSTORYCENSUSDATE == System.DateTime.MinValue) { _plot.UNDERSTORYCENSUSDATE = System.DateTime.Now; } if (_plot.AGEDATE == System.DateTime.MinValue) { _plot.AGEDATE = System.DateTime.Now; } if (_plot.UNDERSTORYVEGETATIONAREA == 0) { _plot.UNDERSTORYVEGETATIONAREA = Constants.DefaultUnderstoryVegArea; } if (_plot.SMALLTREESHRUBAREA == 0) { _plot.SMALLTREESHRUBAREA = Constants.DefaultSmallTreeArea; } if (_plot.LINELENGTH1 == 0 && _plot.VSNPLOTTYPECODE.Contains("C")) { _plot.LINELENGTH1 = Constants.DefaultDWDLineLength; } if (_plot.LINELENGTH2 == 0 && _plot.VSNPLOTTYPECODE.Contains("C")) { _plot.LINELENGTH2 = Constants.DefaultDWDLineLength; } if (util.UseDefaultPerson) { if (_plot.STANDINFOPERSON == null) { _plot.STANDINFOPERSON = util.DefaultPerson; } if (_plot.SMALLTREEPERSON == null) { _plot.SMALLTREEPERSON = util.DefaultPerson; } if (_plot.AGEPERSON == null) { _plot.AGEPERSON = util.DefaultPerson; } if (_plot.FIELD_CREW1 == null) { _plot.FIELD_CREW1 = util.DefaultPerson; } if (_plot.FORESTHEALTHPERSON == null) { _plot.FORESTHEALTHPERSON = util.DefaultPerson; } } // ListPerson = FillPersonPicker().OrderBy(c => c.NAME).ToList(); ListPerson = PickerService.FillPersonPicker(_plotRepository.GetPersonList(_plot.PROJECTID)).OrderBy(c => c.NAME).ToList(); } catch (System.Exception ex) { var msg = ex.Message; } }
public PlotController(PlotRepository plotRepository) { _plotRepository = plotRepository; }