예제 #1
0
        public ActionResult <bool> GenericPost(string typename, [FromBody] JObject post)
        {
            Type type = null;

            try
            {
                type = GetTypeCaseInsensitive($"DatabaseWebService.DatabaseObjects.{typename}");
                if (type == null)
                {
                    throw new Exception("The requested datatype doesnt exist.");
                }

                DbSelector.Insert(post.ToObject(type));
                return(true);
            }
            catch (TargetException)
            {
                var text = type.GetProperties().Aggregate("Supplied a faulty object to the Server. The expected Structure is:\n", (current, prop) => current + $"{prop.Name} : {prop.PropertyType.Name}\n");
                throw new Exception(text);
            }
        }