public async Task <IActionResult> PutAsync(string userId, [FromBody] StudentDetailsArgs args)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!UserPermissions.IsAllowedToModify(User.Identity, userId))
            {
                return(Forbid());
            }

            if (!_userIndex.TryGetInternalId(userId, out var internalId))
            {
                return(NotFound());
            }

            var oldUser = await _eventStore.EventStream.GetCurrentEntityAsync <UserEventArgs>(ResourceTypes.User, internalId);

            var newUser = new UserEventArgs(oldUser)
            {
                StudentDetails = new StudentDetails(args)
            };

            await EntityManager.UpdateEntityAsync(_eventStore, oldUser, newUser, ResourceTypes.User,
                                                  internalId, User.Identity.GetUserIdentity());

            return(NoContent());
        }
Beispiel #2
0
        public StudentDetailsArgs CreateStudentDetailsArgs()
        {
            var args = new StudentDetailsArgs
            {
                Discipline      = Discipline,
                CurrentDegree   = CurrentDegree,
                CurrentSemester = CurrentSemester
            };

            return(args);
        }
Beispiel #3
0
 public StudentDetails(StudentDetailsArgs args)
 {
     Discipline      = args.Discipline;
     CurrentDegree   = args.CurrentDegree;
     CurrentSemester = args.CurrentSemester ?? new int();
 }