/// <summary> /// Update a requirement. /// </summary> /// <param name="requirement">Requirement to update.</param> public void updateRequirement(DTORequirements requirement) { using (DbContext) { // Validate requirement to update if (!updateRequirementIsOk(requirement)) { return; } // Set creation and finalization date var oldRequirement = requirementRepository.getRequirementById(DbContext, requirement); requirement.CreationDate = oldRequirement.CreationDate; requirement.FinalizationDate = oldRequirement.FinalizationDate; // Update requirement and save changes requirementRepository.updateRequirement(DbContext, requirement); DbContext.SaveChanges(); } }
/// <summary> /// Get all the statistic for one requirement. /// </summary> /// <param name="statistic">Dto that contains the id of the requirement.</param> /// <returns>A DTOStatisticView containing all the statistics for on requirement.</returns> public DTOStatisticView getRequirementStatistic(DTOStatisticView statistic) { using (DbContext) { // Get statistics from db var statsFromDb = requirementRepository.getRequirementStatistics(DbContext, statistic); // Do not continue if there is not tasks. var requirementName = requirementRepository.getRequirementById(DbContext, new DTORequirements { Id = statistic.ItemStatisticId }).Name; if (statsFromDb.Count == 0) { return new DTOStatisticView { ItemStatisticName = requirementName, ReturnUrl = statistic.ReturnUrl } } ; // Get and return DTOStatisticView var ret = getDTOStatisticView(statsFromDb, statistic); return(ret); } }