// Register public HttpResponseMessage RegisterLinkedIn(RegisterUserLinkedInRequest model) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } //If email already exists, store their linkedin id > if already stored, return message and continue int userId = _userService.GetByEmail(model.Email); if (userId > 0) { try { ItemResponse<int> resp = new ItemResponse<int>(); resp.Item = _userService.AddLinkedInId(userId, model.LinkedInId); return Request.CreateResponse(HttpStatusCode.OK, resp); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.OK, ex); } } //If no email, create new account, and add linkedin id to linkedin table. try { ItemResponse<int> resp = new ItemResponse<int>(); resp.Item = _userService.RegisterLinkedIn(model); return Request.CreateResponse(HttpStatusCode.OK, resp); } catch (Exception ex) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex); } }
//Register User through LinkedIn Login - sets role to User public int RegisterLinkedIn(RegisterUserLinkedInRequest model) { int Id = 0; DataProvider.ExecuteNonQuery(storedProc : "dbo.UserBaseLinkedIn_Insert", inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Email", model.Email); paramCollection.AddWithValue("@EmailConfirmed", model.EmailConfirmed); paramCollection.AddWithValue("@Locked", model.Locked); paramCollection.AddWithValue("@LinkedInId", model.LinkedInId); paramCollection.AddWithValue("@FirstName", model.FirstName); paramCollection.AddWithValue("@LastName", model.LastName); SqlParameter idParameter = new SqlParameter("@Id", System.Data.SqlDbType.Int); idParameter.Direction = System.Data.ParameterDirection.Output; paramCollection.Add(idParameter); }, returnParameters : delegate(SqlParameterCollection param) { Int32.TryParse(param["@Id"].Value.ToString(), out Id); }); return(Id); }