Example #1
0
        private void Update(HttpContextBase context)
        {
            var item = Selection.ParseSelectionFromRequest();
            if (item == null)
                throw new HttpException((int)HttpStatusCode.NotFound, "Not Found");

            var requestBody = context.GetOrDeserializeRequestStreamJson<object>();
            foreach (var kvp in requestBody)
                item[kvp.Key] = kvp.Value;

            engine.Persister.Save(item);
        }
Example #2
0
        private void Create(HttpContextBase context)
        {
            var parent = Selection.ParseSelectionFromRequest();
            if (parent == null)
                throw new HttpException((int)HttpStatusCode.NotFound, "Not Found");

            var discriminator = context.Request["discriminator"];
            var definition = engine.Definitions.GetDefinition(discriminator);
            
            var item = engine.Resolve<ContentActivator>().CreateInstance(definition.ItemType, parent);

            var requestBody = context.GetOrDeserializeRequestStreamJson<object>();
            foreach (var kvp in requestBody)
                item[kvp.Key] = kvp.Value;

            engine.Persister.Save(item);
        }
Example #3
0
		private void Patch(HttpContextBase context)
		{
			var requestBody = context.GetOrDeserializeRequestStreamJson<object>();
			var user = GetUser(context.User);
			if (requestBody.ContainsKey("Settings") && requestBody["Settings"] is IDictionary<string, object>)
				foreach (var kvp in (IDictionary<string, object>)requestBody["Settings"])
				{
					if (kvp.Value != null)
						user.Settings[kvp.Key] = kvp.Value;
					else
						user.Settings.Remove(kvp.Key);
				}
			repository.Save(user);
			context.Response.WriteJson(new { User = user });
		}