Exemplo n.º 1
0
        public async Task Create(params AchievementModel[] requests)
        {
            foreach (var request in requests)
            {
                await AcademicYearModel.CheckLock(_academicYearRepository, request.AcademicYearId);

                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,
                    RecordedById      = request.RecordedById,
                    CreatedDate       = DateTime.Now
                };

                _achievementRepository.Create(model);
            }

            await _achievementRepository.SaveChanges();
        }
Exemplo n.º 2
0
        public void TryToGiveAchievement(string userID, AchievementTypeEnum achievementType)
        {
            if (achievementRepository.Exists(userID, achievementType))
            {
                return;
            }

            achievementRepository.Add(new Entities.Achievement()
            {
                UserID            = userID,
                AchievementTypeID = (int)achievementType,
                AddDate           = DateTime.Now
            });
            achievementRepository.SaveChanges();
        }