Exemplo n.º 1
0
        public static void Put(string id, UsersProfilesRequest model)
        {
            DataProvider.ExecuteNonQuery(GetConnection, "dbo.UserProfile_Update"
                                         , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@profileName", model.profileName);
                paramCollection.AddWithValue("@profileLastName", model.profileLastName);
                paramCollection.AddWithValue("@profilePhone", model.profilePhone);
                paramCollection.AddWithValue("@profileMobile", model.profileMobile);
                paramCollection.AddWithValue("@profileWebsite", model.profileWebsite);
                paramCollection.AddWithValue("@profileAddress", model.profileAddress);
                paramCollection.AddWithValue("@profileCompany", model.profileCompany);
                paramCollection.AddWithValue("@userId", id);
                paramCollection.AddWithValue("@Tagline", model.Tagline);


                // adding new paramerter
                SqlParameter s = new SqlParameter("@TagsId", SqlDbType.Structured);
                if (model.profileTags != null && model.profileTags.Any())
                {
                    s.Value = new IntIdTable(model.profileTags);
                }
                paramCollection.Add(s);
            }, returnParameters : delegate(SqlParameterCollection param)
            {
            }
                                         );


            foreach (UserExternalAccounts accountInfo in model.ExternalAccounts)
            {
                PostExternalAccounts(accountInfo, id);
            }
        }
Exemplo n.º 2
0
        [Route("currentUser"), HttpPut] //Update profile
        public HttpResponseMessage Update(UsersProfilesRequest model)
        {
            if (model == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Request payload was null"));
            }
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            string id = UserService.GetCurrentUserId();

            UserProfileServices.Put(id, model);
            ItemResponse <bool> response = new ItemResponse <bool>();

            response.Item = true;
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Exemplo n.º 3
0
        public HttpResponseMessage Post(UsersProfilesRequest model)
        {
            if (model == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Fill out all fields"));
            }
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            int userId = UserProfileServices.Post(model);

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

            response.Item = userId;


            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Exemplo n.º 4
0
        public static int Post(UsersProfilesRequest model)
        {
            int OutputId = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.UserProfile_Insert"
                                         , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@profileName", model.profileName);
                paramCollection.AddWithValue("@profileEmail", model.profileEmail);
                paramCollection.AddWithValue("@profilePhone", model.profilePhone);
                paramCollection.AddWithValue("@profileMobile", model.profileMobile);
                paramCollection.AddWithValue("@profileWebsite", model.profileWebsite);
                paramCollection.AddWithValue("@profileAddress", model.profileAddress);
                paramCollection.AddWithValue("@profileCompany", model.profileCompany);
                paramCollection.AddWithValue("@userId", model.userId);
                paramCollection.AddWithValue("@Tagline", model.Tagline);

                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 OutputId);
            }
                                         );

            //creating SystemEvents post for recent activity feed
            SystemEventsRequest newModel = new SystemEventsRequest();

            newModel.ActorUserId = model.userId;
            newModel.EventType   = SystemEventTypes.NewRegister;

            SystemEventsService.Post(newModel);

            return(OutputId);
        }