// Edit edit user profile and ask database to save changes
508954
func (s *service) Edit(reqDTO rest.RequestDTO) (resDTO rest.ResponseDTO, error *servicehelper.Error) {
	entity, err := s.repo.FindByPublicId(reqDTO.PublicId)
	if err != nil {
		return rest.ResponseDTO{}, &servicehelper.Error{Detail: errors.New("no result found"), Code: servicehelper.NotFound}
	}

	entity.FirstName = reqDTO.FirstName
	entity.LastName = reqDTO.LastName
	entity.ProfilePictureUrl = reqDTO.ProfilePictureUrl
	birthday, err := time.Parse("2006-01-02", reqDTO.Birthday)
	if err != nil {
		return rest.ResponseDTO{}, &servicehelper.Error{Detail: errors.New("birthday is malformed"), Code: servicehelper.BadRequest}
	}
	entity.Birthday = &birthday

	if err := s.repo.Update(entity); err != nil {
		return rest.ResponseDTO{}, &servicehelper.Error{
			Detail:  errors.New("could not update profile"),
			Message: "We could not update the profile, please contact us or try again later",
			Code:    servicehelper.UnexpectedError}
	}
	return createDTOFromEntity(entity)
}
225436
func (b *AccountController) Update(c *app.UpdateAccountContext) error {
	account, ok := b.db.GetAccount(c.AccountID)
	if !ok {
		return c.NotFound()
	}
	payload := c.Payload
	if payload.Name != "" {
		account.Name = payload.Name
	}
	b.db.SaveAccount(account)
	return c.NoContent()
}
494061
func (s *UserService) UpdateUser(ctx context.Context, id influxdb.ID, upd influxdb.UserUpdate) (*influxdb.User, error) {
	if err := authorizeWriteUser(ctx, id); err != nil {
		return nil, err
	}

	return s.s.UpdateUser(ctx, id, upd)
}
810048
func (c *UsersClient) Update(ctx context.Context, id ID, updateUser *UpdateUser) (*User, error) {
	idBytes, err := id.MarshalText()
	if err != nil {
		return nil, err
	}

	p := fmt.Sprintf("/users/%s", string(idBytes))

	req, err := c.backend.NewRequest(http.MethodPatch, p, nil, updateUser)
	if err != nil {
		return nil, err
	}

	var resp User
	_, err = c.backend.Do(ctx, req, &resp, func(code int) error {
		return &Error{}
	})
	if err != nil {
		return nil, err
	}

	return &resp, nil
}
1207117
func (c *CodebaseController) Edit(ctx *app.EditCodebaseContext) error {
	listWorkspacesContext := app.ListWorkspacesCodebaseContext{ctx.Context, ctx.ResponseData, ctx.RequestData, ctx.CodebaseID}
	return c.ListWorkspaces(&listWorkspacesContext)
}
810786
func (s *userService) Update(id int64, user datamodels.User) (datamodels.User, error) {
	user.ID = id
	return s.repo.InsertOrUpdate(user)
}
590456
func (r *usersResource) updateUser(request *restful.Request, response *restful.Response, user schema.User) (error, interface{}) {
	var req userReq
	if err := request.ReadEntity(&req); err != nil {
		return err, nil
	}
	u, err := r.users.UpdateUserByEmail(req.Email, req.Fullname)
	if err == nil {
		msg := events.Message{
			// piggy back on addeduser since the client will figure out
			// duplicates and updates.
			Event: "addeduser",
			Data:  u,
		}
		r.hub.Broadcast(msg)
	}
	return err, u
}
921611
func (u *UsersClient) Update(ctx context.Context, userObj interface{}) (envelope.UserInf, error) {
	e := envelope.Unsigned{}
	err := u.client.RoundTrip(ctx, "PATCH", "/users/self", nil, userObj, &e)
	if err != nil {
		return nil, err
	}

	return envelope.ConvertUser(&e)
}
176516
func (f EditorFunc) Edit(v *View, key Key, ch rune, mod Modifier) {
	f(v, key, ch, mod)
}
903570
func (user *User) SaveSetting(key string, value interface{}) error {

	if user.ID == 0 {
		return errors.New("SaveSetting: user is empty")
	}

	key = strings.ToLower(key)
	serviceID := user.ctx.getServiceID()

	var ud userData
	_, err := user.ctx.db.C("users").FindId(user.ID).Select(bson.M{"settings." + serviceID: 1}).
		Apply(
		mgo.Change{
			Update: bson.M{
				"$set":         bson.M{"settings." + serviceID + "." + key: value},
				"$setOnInsert": bson.M{"createdat": time.Now()},
			},
			Upsert:    true,
			ReturnNew: true,
		},
		&ud)

	if err == nil && user.data != nil && user.data.Settings != nil && ud.Settings != nil && ud.Settings[serviceID] != nil {
		user.data.Settings[serviceID] = ud.Settings[serviceID]
	}

	return err
}
451583
func Edit(c *context.APIContext, form api.EditOrgOption) {
	org := c.Org.Organization
	if !org.IsOwnedBy(c.User.ID) {
		c.Status(403)
		return
	}

	org.FullName = form.FullName
	org.Description = form.Description
	org.Website = form.Website
	org.Location = form.Location
	if err := models.UpdateUser(org); err != nil {
		c.Error(500, "UpdateUser", err)
		return
	}

	c.JSON(200, convert.ToOrganization(org))
}
1001973
func savePeopleContext(db *sqlx.DB, in *dt.Msg) error {
	if len(in.StructuredInput.People) == 0 {
		return nil
	}
	byt, err := json.Marshal(in.StructuredInput.People)
	if err != nil {
		return err
	}
	if in.User.ID > 0 {
		q := `INSERT INTO states (key, value, userid, pluginname)
		      VALUES ($1, $2, $3, '')
		      ON CONFLICT (userid, pluginname, key)
		      DO UPDATE SET value=$2`
		_, err = db.Exec(q, keyContextPeople, byt, in.User.ID)
	} else {
		q := `INSERT INTO states
		      (key, value, flexid, flexidtype, pluginname)
		      VALUES ($1, $2, $3, $4, '')
		      ON CONFLICT (flexid, flexidtype, pluginname, key)
		      DO UPDATE SET value=$2`
		_, err = db.Exec(q, keyContextPeople, byt, in.User.FlexID,
			in.User.FlexIDType)
	}
	if err != nil {
		return err
	}
	return nil
}
996017
func UpdatePerson(db *sql.DB, firstName, lastName string, age uint, newPerson Person) error {
	_, err := db.Exec(
		fmt.Sprintf(
			"UPDATE %s SET %s=?,%s=?,%s=? WHERE %s=? AND %s=? AND %s=?",
			PersonTableName,
			PersonFirstNameCol,
			PersonLastNameCol,
			PersonAgeCol,
			PersonFirstNameCol,
			PersonLastNameCol,
			PersonAgeCol,
		),
		newPerson.FirstName,
		newPerson.LastName,
		newPerson.Age,
		firstName,
		lastName,
		age,
	)
	return err
}
1245112
func (user *User) SaveSettings(allSettings interface{}) error {

	serviceID := user.ctx.getServiceID()

	_, err := user.ctx.db.C("users").UpsertId(user.ID, bson.M{"$set": bson.M{"settings." + serviceID: allSettings}, "$setOnInsert": bson.M{"createdat": time.Now()}})

	if user.data == nil {
		user.data = &userData{}
	}
	if user.data.Settings == nil {
		user.data.Settings = make(map[string]interface{})
	}
	user.data.Settings[serviceID] = allSettings

	return err
}
1260238
func UserProfile(c *MyContext) {

	id := c.Param("id")

	var profile string

	// profile = c.AppContext.DB.find(user profile by .....)

	c.AppContext.Log.Println("Found User Profile")

	c.Response().Write([]byte("Here's your profile " + profile + " user " + id))
}
803342
func (au *AuthUser) Save(db XODB) error {
	if au.Exists() {
		return au.Update(db)
	}

	return au.Insert(db)
}
618823
func (r Layout_Profile) ModifyPreferences(layoutPreferenceObjects []datatypes.Layout_Profile_Preference) (resp []datatypes.Layout_Profile_Preference, err error) {
	params := []interface{}{
		layoutPreferenceObjects,
	}
	err = r.Session.DoRequest("SoftLayer_Layout_Profile", "modifyPreferences", params, &r.Options, &resp)
	return
}