Esempio n. 1
0
        protected void resourcesControl_OnEdit(object sender, GenericEventArgs <Guid> e)
        {
            var entity = HbSession.Query <UM_Resource>().FirstOrDefault(n => n.ID == e.Value);

            if (entity == null)
            {
                return;
            }

            var converter = new ResourceEntityModelConverter(HbSession);
            var model     = converter.Convert(entity);

            resourceControl.Model = model;

            mpeResource.Show();
        }
Esempio n. 2
0
        protected void FillResources()
        {
            var filterModel = resourcesFilterControl.Model;

            var query = from n in HbSession.Query <UM_Resource>()
                        where n.DateDeleted == null
                        select n;

            if (filterModel.ProjectID == Guid.Empty)
            {
                query = from n in query
                        where n.ProjectID == null
                        select n;
            }
            else
            {
                query = from n in query
                        where n.ProjectID == filterModel.ProjectID
                        select n;
            }

            var resources = query.ToList();

            var keyword = (filterModel.Keyword ?? String.Empty).Trim();

            if (!String.IsNullOrWhiteSpace(keyword))
            {
                var list = (from n in resources
                            where n.Name.Contains(keyword) ||
                            n.Value.Contains(keyword)
                            select n).ToList();


                var @set = FullHierarchyTraversal(list, resources).ToHashSet();
                resources = @set.ToList();
            }

            var converter = new ResourceEntityModelConverter(HbSession);

            var model = new ResourcesModel
            {
                List = resources.Select(n => converter.Convert(n)).ToList()
            };

            resourcesControl.Model = model;
            resourcesControl.DataBind();
        }