Exemplo n.º 1
0
        public object Register(RegisterViewModel registerViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new BaseResponse(ResponseStatus.ValidationError.ToString(), ModelState.Values.ToList()[0].Errors[0].ErrorMessage)));
            }

            if (_accountLogic.IsUserExist(registerViewModel.EmailAddress.Trim().ToLower()))
            {
                return(Request.CreateResponse(HttpStatusCode.Conflict, new BaseResponse(ResponseStatus.ValidationError.ToString(), ResponseMessagesModel.EmailExist)));
            }

            UserData userData = RegisterViewModel.GetUserData(registerViewModel);

            _accountLogic.Add(userData);

            return(Request.CreateResponse(HttpStatusCode.OK, new BaseResponse(ResponseStatus.Success.ToString(), ResponseMessagesModel.Success)));
        }