public JsonResult Register([FromBody] UserRegistrationModel model) { return(RequestHandlers.Handle(() => { Mapper mapper = new Mapper(); User mappedUser = mapper.ParseUser(model); DbProvider provider = new DbProvider(ctx); if (provider.GetUserByEmail(mappedUser.Email) != null) { throw new ArgumentOutOfRangeException(nameof(model.Email), "Email already exists"); } provider.AddUser(mappedUser); })); }