public UserViewModel Login(UserViewModel viewModel) { if (viewModel.ValidateModelAnnotations().Count > 0) { throw new ModelException( "This object instance is not valid based on DataAnnotation definitions. See more details on Errors list.", viewModel.ValidateModelAnnotations()); } var command = new LoginUserCommand(viewModel.Name, viewModel.Login); var user = Mapper.Map <UserViewModel>(MessageBus.DispatchCommandTwoWay <LoginUserCommand, User>(command) .Result); return(user); }