コード例 #1
0
        public IActionResult PutLayerRelationRule([FromBody] LayerRelationRuleUpdateModel update)
        {
            if (!_annotationPermissions.IsAllowedToCreateRelationRules(User.Identity.GetUserIdentity()))
            {
                return(Forbid());
            }

            try
            {
                if (_tagManager.ChangeLayerRelationRule(update))
                {
                    return(Ok());
                }
                return(NotFound());
            }
            catch (InvalidOperationException)
            {
                return(NotFound());
            }
        }
コード例 #2
0
        internal bool ChangeLayerRelationRule(LayerRelationRuleUpdateModel update)
        {
            if (!(DbContext.Layers.Any(l => l.Id == update.SourceId) &&
                  DbContext.Layers.Any(l => l.Id == update.TargetId)))
            {
                return(false);
            }

            var rule = DbContext.LayerRelationRules.Single(
                r => r.SourceLayerId == update.SourceId &&
                r.TargetLayerId == update.TargetId &&
                r.Title == update.OriginalTitle);

            rule.Title       = update.Title;
            rule.Description = update.Description;
            rule.ArrowStyle  = update.ArrowStyle;
            rule.Color       = update.Color;
            DbContext.SaveChanges();
            return(true);
        }