Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> Add(UserAddRequest request, string role = null)
        {
            int userId = 0;

            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            ;

            //fix create below

            try
            {
                userId = _userService.Create(request, role);
            }
            catch (Exception)
            {
                ErrorResponse error = new ErrorResponse("There was an error creating your account.");
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, error));
            }



            int  TokenTypeId = 2;
            Guid getToken    = _tokenService.GenerateToken(userId, TokenTypeId);
            bool result      = await _emailService.ConfirmationSend(request, getToken);

            ItemResponse <int> resp = new ItemResponse <int>();

            resp.Item = userId;

            return(Request.CreateResponse(HttpStatusCode.OK, resp));
        }