public static Orchestrators.PatchUserModel ToPatchUserModel(this API.PatchUserInputModel source, string subjectId)
        {
            var target = new Orchestrators.PatchUserModel()
            {
                SubjectId = subjectId
            };

            var properties = new List <KeyValuePair <string, string> >();

            foreach (var item in source.Properties)
            {
                if (item.Value is JArray)
                {
                    var values = item.Value.ToArray();
                    foreach (var value in values)
                    {
                        properties.Add(new KeyValuePair <string, string>(item.Key, NormalizeEmptyString(value.ToString())));
                    }
                }
                else
                {
                    properties.Add(new KeyValuePair <string, string>(item.Key, NormalizeEmptyString(item.Value.ToString())));
                }
            }
            target.Properties = properties.ToLookup(x => x.Key, x => x.Value);
            return(target);
        }
Example #2
0
 public async Task<ActionResponse> PatchUserAsync(PatchUserModel model)
 {
     if (!OperatingOnSelf(model.SubjectId))
     {
         return PermissionDenied();
     }
     var user = await _userStore.GetUserAsync(model.SubjectId, true);
     if (user == null)
     {
         return BadRequest("User does not exist");
     }
     var updatedUser = await _userStore.PatchUserAsync(model.SubjectId, model.Properties);
     return new ActionResponse(updatedUser);
 }