Example #1
0
        public async Task <ActionResult> UpdateUser(MembersUpdateDto membersUpdateDto)
        {
            var user = await _userRepository.GetUserByUsernameAsync(User.GetUsername());

            _mapper.Map(membersUpdateDto, user);

            _userRepository.Update(user);

            if (await _userRepository.SaveAllAsync())
            {
                return(NoContent());
            }

            return(BadRequest("Failed to update user"));
        }
Example #2
0
        public IActionResult UpdateMember([FromBody] MembersUpdateDto member)
        {
            var memberToUpdate = _memberInfoRepository.GetMembers().FirstOrDefault(x => x.id == member.id);

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

            var newMember = new Member
            {
                id          = member.id,
                fname       = member.fname,
                lname       = member.lname,
                description = member.description
            };

            _memberInfoRepository.UpdateMember(newMember);
            if (!_memberInfoRepository.Save())
            {
                return(StatusCode(500, "Updating member was not successfull"));
            }
            return(Ok(newMember));
        }