Example #1
0
        // TODO breeze doesn't support this at the moment / coni2k - 31 Jul. '17
        // [ConcurrencyValidator(typeof(ElementCell))]
        public async Task <IHttpActionResult> Delete(int key)
        {
            var elementCell = await _resourcePoolManager.GetElementCellSet(key, true, item => item.ElementField.Element.ResourcePool).SingleOrDefaultAsync();

            // Owner check: Entity must belong to the current user
            var currentUserId = User.Identity.GetUserId <int>();

            if (currentUserId != elementCell.ElementField.Element.ResourcePool.UserId)
            {
                return(StatusCode(HttpStatusCode.Forbidden));
            }

            await _resourcePoolManager.DeleteElementCellAsync(elementCell.Id);

            return(StatusCode(HttpStatusCode.NoContent));
        }