Beispiel #1
0
        public static int InsertRegistration(RegistrationAddRequest model, string userId)
        {
            int id = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Users_Insert"   //this is the proc name
               , inputParamMapper: delegate(SqlParameterCollection paramCollection)
               {
                   paramCollection.AddWithValue("@FirstName", model.FirstName);
                   paramCollection.AddWithValue("@LastName", model.LastName);
                   paramCollection.AddWithValue("@Phone", model.Phone);
                   paramCollection.AddWithValue("@UserId", userId);

                   SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int);
                   p.Direction = System.Data.ParameterDirection.Output;

                   paramCollection.Add(p);

               }, returnParameters: delegate(SqlParameterCollection param)
               {
                   int.TryParse(param["@Id"].Value.ToString(), out id);
               }
               );

            return id;
        }
Beispiel #2
0
        public HttpResponseMessage RegistrationAdd(RegistrationAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            try
            {
                IdentityUser user = UserService.CreateUser(model.Email, model.Password);

                UserService.InsertRegistration(model, user.Id);

                //_messagingService.SendConfirmationEmail(model, user.Id);

                return Request.CreateResponse(user);

            }
            catch (IdentityResultException ire)
            {

                ErrorResponse er = new ErrorResponse(ire.Result.Errors);

                return Request.CreateResponse(HttpStatusCode.InternalServerError, er);

            }
            catch (Exception e)
            {
                ErrorResponse er = new ErrorResponse(e.Message);

                return Request.CreateResponse(HttpStatusCode.InternalServerError, er);

            }
        }