Example #1
0
        public async Task <IActionResult> Update([FromHeader] string authToken, string id, LabCourseUpdate update)
        {
            if (!await _authenticationService.CheckAccess(authToken, "courseMgr"))
            {
                return(Unauthorized());
            }

            LabCourse course = await _labCourseService.Get(id);

            if (course == null)
            {
                return(NotFound());
            }

            _labCourseService.Update(course, update);

            await _logService.Create(new Log(
                                         null,
                                         AuthenticationHelpers.GetUserIdFromToken(authToken),
                                         DateTime.UtcNow,
                                         "Document modified.",
                                         "labCourses",
                                         id,
                                         JsonSerializer.Serialize(LabCourse.FromUpdate(course, update))
                                         ));

            return(Ok());
        }
 public async void Update(LabCourse original, LabCourseUpdate update) =>
 await _labCourses.ReplaceOneAsync(labCourse => labCourse.Id == original.Id, LabCourse.FromUpdate(original, update));