Exemple #1
0
        public async Task<IHttpActionResult> Add(HomeworkViewModel hw)
        {
            string token = Request.Headers.GetValues("Authorization").FirstOrDefault();
            HomeworkDTO dtoHw = Mapper.Map<HomeworkDTO>(hw);
            dtoHw.Module = _moduleProvider.GetById(hw.ModuleId);
            _homeworkProvider.CreateHomework(dtoHw);

            Logger.Logger.Instance.LogAction(LoggerHelper.GetActionString(TokenHelper.GetFromToken(token, "username"), "Homework created"));
            return Content(HttpStatusCode.OK, "Created successfully");
        }
Exemple #2
0
 public async Task<IHttpActionResult> Update(HomeworkViewModel hw)
 {
     string token = Request.Headers.GetValues("Authorization").FirstOrDefault();
     try
     {
         _homeworkProvider.UpdateHomework(Mapper.Map<HomeworkDTO>(hw));
         Logger.Logger.Instance.LogAction(
             LoggerHelper.GetActionString(TokenHelper.GetFromToken(token, "username"), "Homework updated"));
         return Ok();
     }
     catch (Exception ex)
     {
         Logger.Logger.Instance.LogError(ex);
         return BadRequest(ex.Message);
     }
 }