public void UnfreezeMonthlyProjectData(int month, int year, int projectId, ProjectLockedUnlockedHistory projectLockedUnlockedHistory) { // get project and monthly project data entities var monthlyProjectData = _monthlyProjectDataRepository.GetMonthlyProjectData(month, year, projectId).First(); var project = _projectsRepository.GetProject(projectId); var monthlyBilledHours = monthlyProjectData.MonthlyBilledHours; var monthlyBilledAmount = monthlyProjectData.MonthlyBilledAmount; // modify project data properties project.TotalBilledAmount -= monthlyBilledAmount; project.TotalBilledHours -= monthlyBilledHours; project.LastBilledDate = DateTime.Now; // modify monthly project data properties monthlyProjectData.LastUpdatedOn = DateTime.Now; monthlyProjectData.IsLocked = !monthlyProjectData.IsLocked; // modify project locked unlocked history projectLockedUnlockedHistory.UpdatedOn = DateTime.Now; // update project in db _projectsRepository.UpdateProject(projectId, project); // update monthyProjectData in db _monthlyProjectDataRepository.UpdateMonthlyProjectData(month, year, projectId, monthlyProjectData); // add a new entry to the project Locked Unlocked History table in db _projectLockedUnlockedHistoryRepository.AddHistory(projectLockedUnlockedHistory); }
public ActionResult UnfreezeMonthlyProjectData(int month, int year, int projectId, ProjectLockedUnlockedHistory projectLockedUnlockedHistory) { _monthlyProjectDataService.UnfreezeMonthlyProjectData(month, year, projectId, projectLockedUnlockedHistory); return(Ok(projectLockedUnlockedHistory)); }
public ProjectLockedUnlockedHistory AddHistory(ProjectLockedUnlockedHistory projectLockedUnlockedHistory) { _context.ProjectLockedUnlockedHistorys.Add(projectLockedUnlockedHistory); _context.SaveChanges(); return(projectLockedUnlockedHistory); }