Ejemplo n.º 1
0
        public HandlerResponse DeleteRoom(DeleteRoomCommand input)
        {
            var handler = _deleteHandlerFactory.CreateHandler <DeleteRoomCommand, Room>();
            var result  = handler.Create(input);

            return(result);
        }
Ejemplo n.º 2
0
        public CommandResult Delete(string roomId)
        {
            DeleteRoomCommand command = new DeleteRoomCommand();

            command.SetRoomId(roomId);

            return(Execute <DeleteRoomCommand, CommandResult>(command));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> DeleteRoom(int id)
        {
            var deleteRoomCommand = new DeleteRoomCommand()
            {
                Id = id
            };
            await _mediator.Send(deleteRoomCommand);

            return(NoContent());
        }
Ejemplo n.º 4
0
        public CommandResult Handle(DeleteRoomCommand 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)
                {
                    _roomRepository.Delete(room);

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

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

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

            return(result);
        }
        public async Task <Unit> Handle(DeleteRoomCommand request, CancellationToken cancellationToken)
        {
            await _roomService.DeleteRoomAsync(request.Id);

            return(Unit.Value);
        }