Exemple #1
0
        public async Task <IActionResult> Update([FromBody] UpdateMemberCommand command)
        {
            command.ManagerId = User.Identity.Name;
            await mediator.Send(command);

            return(Ok());
        }
Exemple #2
0
        public async Task <IHttpActionResult> Update(long memberId, [FromBody] UpdateMemberCommand updateCommand)
        {
            updateCommand.Id = memberId;
            await _mediator.Send(updateCommand);

            return(StatusCode(System.Net.HttpStatusCode.NoContent));
        }
Exemple #3
0
        public async Task <IActionResult> UpdateAsync([FromBody] UpdateMemberCommand command,
                                                      CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(command, cancellationToken);

            return(result.Failures.Any() ? BadRequest(result.GenerateFailuresOutput()) as IActionResult : Ok(result.Data));
        }
Exemple #4
0
        public void SetValues <T>(T[] values)
        {
            Debug.Assert(typeof(T).IsAssignableFrom(type),
                         string.Format("Type missmatch, {0} : {1}.", typeof(T).Name, type.Name));
            foreach (var mi in mMemberPath)
            {
                if (mi.MemberType == MemberTypes.Field)
                {
                    Debug.Assert(!((FieldInfo)mi).IsLiteral && !((FieldInfo)mi).IsInitOnly);
                }
                else if (mi.MemberType == MemberTypes.Property)
                {
                    Debug.Assert(((PropertyInfo)mi).CanWrite);
                }
            }

            var objects = persistentObject.GetValues <object>();

            Debug.Assert(values.Length == objects.Length);
            var commands = new UpdateMemberCommand[objects.Length];

            for (var i = 0; i < objects.Length; i++)
            {
                commands[i] = new UpdateMemberCommand(objects[i], propertyPath, values[i]);
            }

            Command.Execute(new CombinedCommand(commands));
        }
        public async Task <IActionResult> Put(Guid eventId, string userId, [FromBody] UpdateMemberCommand message)
        {
            message.EventId = eventId;
            message.UserId  = userId;

            await _mediator.Send(message);

            return(NoContent());
        }
Exemple #6
0
        public async Task <ApiResponse <Member> > Handle(UpdateMemberCommand request, CancellationToken cancellationToken)
        {
            var updatedMember = await _memberRepository.GetForGuildOperationsAsync(request.Id, cancellationToken);

            updatedMember.ChangeName(request.Name);
            if (request.GuildId is { } guildId&& guildId != Guid.Empty)
            {
                var invitingGuild = await _guildRepository.GetForMemberHandlingAsync(guildId, cancellationToken);

                invitingGuild.Invite(updatedMember).BeAccepted();
            }
Exemple #7
0
        public async Task <ActionResult> Put(int id, [FromBody] UpdateMemberCommand command)
        {
            if (id != command.EntityId)
            {
                return(BadRequest());
            }

            await _mediator.Send(command);

            return(NoContent());
        }
        public async Task <UpdateMemberCommandResult> UpdateMemberCommandHandler(UpdateMemberCommand command)
        {
            var member = await _memberRepository.ByIdAsync(command.Id);

            _mapper.Map <UpdateMemberCommand, Member>(command, member);

            var affectedRecordsCount = await _memberRepository.UpdateRecordAsync(member);

            return(new UpdateMemberCommandResult()
            {
                Succeed = affectedRecordsCount < 1
            });
        }
        public static UpdateMemberCommand ToUpdateMemberCommand(this MemberVm model)
        {
            var command = new UpdateMemberCommand()
            {
                Id        = model.Id,
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Roles     = model.Roles,
                Avatar    = model.Avatar,
                Email     = model.Email
            };

            return(command);
        }
        public async Task <IActionResult> Update(Guid id, UpdateMemberCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var result = await _memberService.UpdateMemberCommandHandler(command);

                return(Ok(result));
            }
            catch (NotFoundException <Guid> )
            {
                return(NotFound());
            }
        }
        public async Task <UpdateMemberCommandResult> UpdateMemberCommandHandler(UpdateMemberCommand command)
        {
            var isSucceed = true;
            var member    = await _memberRepository.ByIdAsync(command.Id);

            _mapper.Map(command, member);

            var affectedRecordsCount = await _memberRepository.UpdateRecordAsync(member);

            if (affectedRecordsCount < 1)
            {
                isSucceed = false;
            }

            return(new UpdateMemberCommandResult
            {
                Succeed = isSucceed
            });
        }
 public async Task <UpdateMemberCommandResult> Update(UpdateMemberCommand command)
 {
     return(await _httpClient.PutJsonAsync <UpdateMemberCommandResult>($"members/{command.Id}", command));
 }
 public void UpdateMembership(UpdateMemberCommand request)
 {
     throw new NotImplementedException();
 }
Exemple #14
0
 public async Task <ActionResult <int> > Update(UpdateMemberCommand command)
 {
     return(await Mediator.Send(command));
 }
Exemple #15
0
 public async Task <IActionResult> UpdateMember([FromBody] UpdateMemberCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }