public HandlerResponse DeleteRoom(DeleteRoomCommand input) { var handler = _deleteHandlerFactory.CreateHandler <DeleteRoomCommand, Room>(); var result = handler.Create(input); return(result); }
public CommandResult Delete(string roomId) { DeleteRoomCommand command = new DeleteRoomCommand(); command.SetRoomId(roomId); return(Execute <DeleteRoomCommand, CommandResult>(command)); }
public async Task <ActionResult> DeleteRoom(int id) { var deleteRoomCommand = new DeleteRoomCommand() { Id = id }; await _mediator.Send(deleteRoomCommand); return(NoContent()); }
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); }