Example #1
0
        public async Task <ActionResult> Post([FromBody] CommandCreateUser command,
                                              [FromServices] CreateUserHandler handler)
        {
            var result = (CommandResult)handler.handle(command);

            if (!result.Success)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }
Example #2
0
        /// <summary>
        /// Method to Create users using the Commands
        /// </summary>
        /// <param name="user">User to be created</param>
        /// <returns>User</returns>
        public User CreateUser(User user)
        {
            try
            {
                Command <Entity, Entity> CommandCreateUser;
                CommandCreateUser = FactoryCommand.GetCommandCreateUser();

                return((User)CommandCreateUser.Execute(user));
            }
            catch (Exception e)
            {
                Command <Exception, bool> CommandCreateLog;
                CommandCreateLog = FactoryCommand.GetCommandCreateLog();
                CommandCreateLog.Execute(e);
            }

            return(null);
        }