public async Task UpdateAchievement(params UpdateAchievementModel[] requests) { using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork()) { foreach (var request in requests) { var achievementInDb = await unitOfWork.Achievements.GetById(request.Id); if (achievementInDb == null) { throw new NotFoundException("Achievement not found."); } await AcademicHelper.IsAcademicYearLocked(achievementInDb.AcademicYearId, true); achievementInDb.AchievementTypeId = request.AchievementTypeId; achievementInDb.LocationId = request.LocationId; achievementInDb.OutcomeId = request.OutcomeId; achievementInDb.Comments = request.Comments; achievementInDb.Points = request.Points; await unitOfWork.Achievements.Update(achievementInDb); } await unitOfWork.SaveChangesAsync(); } }
public async Task CreateAchievement(Guid userId, params CreateAchievementModel[] requests) { using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork()) { foreach (var request in requests) { await AcademicHelper.IsAcademicYearLocked(request.AcademicYearId, true); var model = new Achievement { AcademicYearId = request.AcademicYearId, AchievementTypeId = request.AchievementTypeId, LocationId = request.LocationId, StudentId = request.StudentId, Comments = request.Comments, OutcomeId = request.OutcomeId, Points = request.Points, CreatedById = userId, CreatedDate = DateTime.Now }; unitOfWork.Achievements.Create(model); } await unitOfWork.SaveChangesAsync(); } }
public async Task Update(params UpdateLogNoteModel[] logNoteObjects) { using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork()) { foreach (var logNoteObject in logNoteObjects) { var logNote = await unitOfWork.LogNotes.GetById(logNoteObject.Id); await AcademicHelper.IsAcademicYearLocked(logNote.AcademicYearId, true); var updateDate = DateTime.Now; if (logNote == null) { throw new NotFoundException("Log note not found."); } logNote.TypeId = logNoteObject.TypeId; logNote.Message = logNoteObject.Message; await unitOfWork.LogNotes.Update(logNote); } await unitOfWork.SaveChangesAsync(); } }
public async Task Create(Guid userId, params CreateLogNoteModel[] logNoteObjects) { using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork()) { foreach (var logNoteObject in logNoteObjects) { await AcademicHelper.IsAcademicYearLocked(logNoteObject.AcademicYearId, true); var createDate = DateTime.Now; var logNote = new LogNote { TypeId = logNoteObject.TypeId, Message = logNoteObject.Message, StudentId = logNoteObject.StudentId, CreatedDate = createDate, CreatedById = userId, AcademicYearId = logNoteObject.AcademicYearId }; unitOfWork.LogNotes.Create(logNote); } await unitOfWork.SaveChangesAsync(); } }
public async Task DeleteAchievement(params Guid[] achievementIds) { using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork()) { foreach (var achievementId in achievementIds) { var achievement = await GetAchievementById(achievementId); await AcademicHelper.IsAcademicYearLocked(achievement.AcademicYearId, true); await unitOfWork.Achievements.Delete(achievementId); } await unitOfWork.SaveChangesAsync(); } }
public async Task Delete(params Guid[] logNoteIds) { using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork()) { foreach (var logNoteId in logNoteIds) { var logNote = await GetById(logNoteId); await AcademicHelper.IsAcademicYearLocked(logNote.AcademicYearId, true); await unitOfWork.LogNotes.Delete(logNoteId); } await unitOfWork.SaveChangesAsync(); } }