示例#1
0
    public async Task <ResourceDto> NewResource()
    {
        var resource = new ResourceEditorComponent(Store);

        resource.AutoDBSave = false;  // don't save automatically

        await resource.NewModel(Service);

        resource.Model.NoteId = Model.NoteId;
        resource.Model.SetIsNew(true);

        var res = resource.RunModal();

        if (res.Entity == EComponentResult.Executed)
        {
            Model.Resources.Add(resource.Model);
            return(resource.Model);
        }
        else if (res.Entity == EComponentResult.Error)
        {
            View.ShowInfo($"Error: {res.Message}");
            return(null);
        }
        else
        {
            return(null);
        }
    }
示例#2
0
    public async Task <ResourceDto> EditResource(Guid resourceId)
    {
        var resourceEditor = new ResourceEditorComponent(Store);

        resourceEditor.AutoDBSave = false;  // don't save automatically

        var resource = Model.Resources.Where(_ => _.ResourceId == resourceId).SingleOrDefault();

        resourceEditor.LoadModel(Service, resource, false);

        var dummy = await Task.FromResult(true);

        var res = resourceEditor.RunModal();

        if (res.Entity == EComponentResult.Executed)
        {
            return(resourceEditor.Model);
        }
        else
        {
            return(null);
        }
    }