Exemple #1
0
        public async Task <IActionResult> Update(int id, UpdateRoomCommand command)
        {
            command.RoomId = id;
            await Mediator.Send(command);

            return(NoContent());
        }
Exemple #2
0
 public async Task UpdateRoom(
     [FromServices] UpdateRoomCommand command, [FromBody] RoomInput input,
     [FromRoute] Guid roomId
     )
 {
     await command.ExecuteAsync(roomId, input);
 }
        public async Task <Unit> Handle(UpdateRoomCommand request, CancellationToken cancellationToken)
        {
            var room = _mapper.Map <Domain.Models.Room>(request);
            await _roomService.UpdateRoomAsync(room);

            return(Unit.Value);
        }
 public void Handle(UpdateRoomCommand Message)
 {
     if (Message != null)
     {
         var room = _mapper.Map <Room>(Message);
         _repository.Update(room);
     }
 }
        public async Task <ActionResult <Room> > Update([FromRoute] int id, [FromBody] UpdateRoomCommand value)
        {
            var message = new Message {
                From = "from@email", To = "to@email", Subject = "Notification", Body = "UPDATED", Password = ""
            };
            var notificationService = new NotificationService();
            await notificationService.SendAsync(message);

            return(Ok(await Mediator.Send(command)));
        }
Exemple #6
0
        public CommandResult Update(string roomId, [FromBody] UpdateRoomCommand command)
        {
            if (command == null)
            {
                command = new UpdateRoomCommand();
            }

            command.SetRoomId(roomId);

            return(Execute <UpdateRoomCommand, CommandResult>(command));
        }
        public CommandResult Handle(UpdateRoomCommand command)
        {
            CommandResult result = new CommandResult();

            ObjectId roomId = new ObjectId();

            if (!ObjectId.TryParse(command.RoomId, out roomId))
            {
                AddNotification(nameof(command.RoomId), ENotifications.InvalidFormat);
            }

            if (Valid)
            {
                Room room = _roomRepository.Get(roomId);

                if (room == null && _roomRepository.Valid)
                {
                    AddNotification(nameof(command.RoomId), ENotifications.NotFound);
                }

                if (Valid)
                {
                    room.Update(command.Description);

                    if (room.Valid)
                    {
                        _roomRepository.Update(room);

                        if (_roomRepository.Valid)
                        {
                            result = new CommandResult(HttpStatusCode.OK);
                        }
                    }

                    else
                    {
                        result = new CommandResult(HttpStatusCode.BadRequest, room.Notifications);
                    }
                }

                else
                {
                    result = new CommandResult(HttpStatusCode.BadRequest, Notifications);
                }
            }

            else
            {
                result = new CommandResult(HttpStatusCode.BadRequest, Notifications);
            }

            return(result);
        }
Exemple #8
0
        public async Task <ActionResult <RoomViewModel> > Update(int id, [FromBody] UpdateRoomCommand command)
        {
            await Mediator.Send(command);

            return(NoContent());
        }
        public async Task <IActionResult> UpdateRoom([FromBody] UpdateRoomCommand data)
        {
            var res = await Mediator.Send(data);

            return(res == null ? (IActionResult)BadRequest("Unable to update the data") : Ok(res));
        }
Exemple #10
0
 public async Task <ActionResult <RoomViewModel> > Update([FromBody] UpdateRoomCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }
Exemple #11
0
        public async Task <IActionResult> Update([FromBody] UpdateRoomCommand command)
        {
            await Mediator.Send(command);

            return(NoContent());
        }
Exemple #12
0
 public async Task <ActionResult <RoomDto> > Update([FromRoute] int id, [FromBody] UpdateRoomCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }
Exemple #13
0
 public async Task <IActionResult> Put(Guid id, [FromBody] UpdateRoomCommand request)
 {
     request.Id = id;
     return(await CreateResponse(async() => await _mediator.Send(request)));
 }
 public async Task <ActionResult> Update([FromBody] UpdateRoomCommand room)
 {
     return(Ok(await Mediator.Send(room)));
 }