コード例 #1
0
 public int DeleteById(int id)
 {
     // odstranit všechny podřízené definice dotací
     var definitionsApi = new GrantDefinitionsApiController();
     foreach (var definition in definitionsApi.GetAll(id))
     {
         definitionsApi.DeleteById(definition.Id);
     }
     // odstranit dotaci
     return DatabaseContext.Database.Delete<Grant>(id);
 }
コード例 #2
0
        protected override TreeNodeCollection GetTreeNodes(string id, System.Net.Http.Formatting.FormDataCollection queryStrings)
        {
            var grants = new GrantsApiController();
            var grantDefs = new GrantDefinitionsApiController();

            //check if we're rendering the root node's children
            if (id == Constants.System.Root.ToInvariantString())
            {
                var nodes = new TreeNodeCollection();

                foreach (var grant in grants.GetAll())
                {
                    string grantId = GrantPrefix + grant.Id.ToString();
                    var node = CreateTreeNode(
                        grantId,
                        "-1",
                        queryStrings,
                        grant.ToString(),
                        "icon-coins-euro-alt",
                        true);
                    // FormDataCollectionExtensions.GetValue<string>(queryStrings, "application") + StringExtensions.EnsureStartsWith(this.TreeAlias, '/') + "/overviewCalendar/all");

                    // definice dotací
                    /*
                    foreach (var grantDef in grantDefs.GetAll())
                    {
                        var chNode = CreateTreeNode(
                            GrantDefinitionPrefix + grantDef.Id.ToString(),
                            grantId,
                            queryStrings,
                            grantDef.ToString(),
                            "icon-car",
                            false);

                        nodes.Add(chNode);
                    }*/

                    nodes.Add(node);

                }
                return nodes;
            }
            else if (id.StartsWith(GrantPrefix))
            {

                var tree = new TreeNodeCollection();

                foreach (var grantDef in grantDefs.GetAll(int.Parse(id.Replace(GrantPrefix, ""))))
                {
                    var treeNodeId = GrantDefinitionPrefix + grantDef.Id.ToString();
                    tree.Add(CreateTreeNode(
                        treeNodeId,
                        id,
                        queryStrings,
                        grantDef.ToString(),
                        "icon-calendar",
                        false,
                        FormDataCollectionExtensions.GetValue<string>(queryStrings, "application") + StringExtensions.EnsureStartsWith(this.TreeAlias, '/') + "/editGrantDef/" + treeNodeId
                        )
                    );
                    //, FormDataCollectionExtensions.GetValue<string>(queryStrings, "application") + StringExtensions.EnsureStartsWith(this.TreeAlias, '/') + "/editCalendar/" + cal.Id));
                }
                return tree;
            }

            //this tree doesn't suport rendering more than 1 level
            throw new NotSupportedException();
        }