Beispiel #1
0
        public virtual async Task <ActionResult> Get(TKey id)
        {
            var entity = Crud.Find(id);

            if (entity == null)
            {
                return(HttpNotFound());
            }

            return(new JsonResult()
            {
                Data = entity
            });
        }
Beispiel #2
0
        public static void EnsureEntity <T, TKey>(this CrudBase <T, TKey> crud, TKey id, Action <T> update)
            where T : class
        {
            var entity = crud.Find(id);

            if (entity == null)
            {
                entity = Activator.CreateInstance <T>();
                crud.SetEntityId(entity, id);
                crud.Add(entity);
            }
            update(entity);
        }
Beispiel #3
0
        public virtual async Task <IActionResult> Patch(TKey id, [FromBody] JObject value)
        {
            var entity = Crud.Find(id);

            return(await Patch(id, entity, value));
        }