Exemple #1
0
        public async Task<IHttpActionResult> UpdateGrade(StudentTestDTO studentTest)
        {
            string token = Request.Headers.GetValues("Authorization").FirstOrDefault();
            var studentTestDTO = Mapper.Map<StudentTestDTO>(studentTest);
            //hwDTO.Files.Add(_fileRepo.Get(f=>f.Id == fileId));
            _studentTestProvider.CreateStudentTest(studentTestDTO);

            Logger.Logger.Instance.LogAction(LoggerHelper.GetActionString(TokenHelper.GetFromToken(token, "username"), "Grade updated"));
            return Content(HttpStatusCode.OK, "Updated successfully");
        }
 public void CreateStudentTest(StudentTestDTO studentTest)
 {
     var entry =
         _studentTestRepository.Get(
             s => s.DomainUserId.Equals(studentTest.StudentId) && s.TestId.Equals(studentTest.TestId));
     if (entry == null)
     {
         var c = Mapper.Map<StudentTest>(studentTest);
         c.DomainUser = _userRepo.Get(u => u.DomainUserId == studentTest.StudentId);
         c.Test = _testRepo.Get(h => h.TestId == studentTest.TestId);
         c.Grade = studentTest.Grade;
         _studentTestRepository.Add(c);
     }
     else
     {
         entry.Grade = studentTest.Grade;
         _studentTestRepository.SaveChanges();
     }
 }