Exemple #1
0
 protected void FillGroupForm(UM_Group @group)
 {
     hdMainGroupID.Value       = @group.ID.ToString();
     hdMainGroupParentID.Value = @group.ProjectID.ToString();
     hdParentID.Value          = @group.ParentID.ToString();
     tbGroupName.Text          = @group.Name;
 }
Exemple #2
0
    protected UM_Group GetRootGroup(UM_Group upperLevelGroup, UM_Group group)
    {
        while (group.Parent != null && group.ID != upperLevelGroup.ID)
        {
            group = group.Parent;
        }

        return(group);
    }
Exemple #3
0
        protected void btGroupOK_Click(object sender, EventArgs e)
        {
            var model = groupControl.Model;

            if (String.IsNullOrWhiteSpace(model.Name))
            {
                lblGroupError.Text = "შეიყვანეთ სახელი";

                mpeGroup.Show();
                return;
            }

            var parent  = HbSession.Query <UM_Group>().FirstOrDefault(n => n.ID == model.ParentID);
            var project = HbSession.Query <UM_Project>().FirstOrDefault(n => n.ID == model.ProjectID);

            if (project == null && parent != null)
            {
                var grandParent = parent;

                while (grandParent.Parent != null)
                {
                    grandParent = grandParent.Parent;
                }

                model.ProjectID = grandParent.ProjectID;
            }

            var group = HbSession.Query <UM_Group>().FirstOrDefault(n => n.ID == model.ID);

            if (group == null)
            {
                group = new UM_Group
                {
                    ID          = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                };
            }

            var converter = new GroupModelEntityConverter(HbSession);

            converter.FillObject(group, model);

            HbSession.SubmitChanges(group);

            FillGroupsTree();

            mpeGroup.Hide();
        }
Exemple #4
0
        public static GroupContract ToContract(this UM_Group entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var contract = new GroupContract();

            contract.DateChanged = entity.DateChanged;
            contract.DateCreated = entity.DateCreated;
            contract.DateDeleted = entity.DateDeleted;
            contract.ID          = entity.ID;
            contract.ParentID    = entity.ParentID;
            contract.Name        = entity.Name;
            contract.ProjectID   = entity.ProjectID;

            return(contract);
        }
Exemple #5
0
        public static UM_Group ToEntity(this GroupContract contract)
        {
            if (contract == null)
            {
                return(null);
            }

            var entity = new UM_Group();

            entity.DateChanged = contract.DateChanged;
            entity.DateCreated = contract.DateCreated;
            entity.DateDeleted = contract.DateDeleted;
            entity.ID          = contract.ID;
            entity.ParentID    = contract.ParentID;
            entity.Name        = contract.Name;
            entity.ProjectID   = contract.ProjectID;

            return(entity);
        }
Exemple #6
0
    protected void btGroupOK_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrWhiteSpace(tbGroupName.Text))
        {
            lblGroupError.Text = "შეიყვანეთ სახელი";

            upnlGroup.Update();
            mpeGroup.Show();

            return;
        }

        if (String.IsNullOrWhiteSpace(hdMainGroupParentID.Value))
        {
            lblGroupError.Text = "მონიშნეთ პროექტი";

            upnlGroup.Update();
            mpeGroup.Show();

            return;
        }

        var projectID = Guid.Parse(hdMainGroupParentID.Value);

        var project = DataContext.UM_Projects.FirstOrDefault(n => n.ID == projectID);

        if (project == null)
        {
            return;
        }

        UM_Group group;

        Guid groupID;

        if (Guid.TryParse(hdMainGroupID.Value, out groupID))
        {
            group = DataContext.UM_Groups.FirstOrDefault(n => n.ID == groupID);
            if (group == null)
            {
                return;
            }
        }
        else
        {
            group             = new UM_Group();
            group.ID          = Guid.NewGuid();
            group.DateCreated = DateTime.Now;
            DataContext.UM_Groups.InsertOnSubmit(group);
        }


        group.Name      = tbGroupName.Text;
        group.ProjectID = Guid.Parse(hdMainGroupParentID.Value);
        var parentID = hdParentID.Value;

        if (parentID == String.Empty)
        {
            group.ParentID = null;
        }
        else
        {
            group.ParentID = Guid.Parse(parentID);
        }

        DataContext.SubmitChanges();

        CacheEntitiesUtil.ResetAll();
        tlGroups.RefreshVirtualTree();
    }