public EntityGroupDTO ToEntityGroupDTO(DR_Requester requester, EntityGroup item, bool withDetails) { EntityGroupDTO result = new EntityGroupDTO(); result.ID = item.ID; result.Name = item.Name; if (withDetails) { foreach (var ritem in item.EntityGroup_Relationship) { if (DataIsAccessable(requester, ritem)) { EntityGroupRelationshipDTO egr = ToEntityGroupRelationshipDTO(ritem, withDetails); result.Relationships.Add(egr); } } } return(result); }
public int UpdateEntityGroups(EntityGroupDTO message) { using (var projectContext = new DataAccess.MyProjectEntities()) { var dbEntityGroup = projectContext.EntityGroup.FirstOrDefault(x => x.ID == message.ID); if (dbEntityGroup == null) { dbEntityGroup = new DataAccess.EntityGroup(); } dbEntityGroup.ID = message.ID; dbEntityGroup.ProcessID = message.ProcessID; dbEntityGroup.Name = message.Name; while (dbEntityGroup.EntityGroup_Relationship.Any()) { projectContext.EntityGroup_Relationship.Remove(dbEntityGroup.EntityGroup_Relationship.First()); } foreach (var msg in message.Relationships) { var db = new EntityGroup_Relationship(); if (msg.RelationshipTailID != 0) { db.EntityRelationshipTailID = msg.RelationshipTailID; } else { db.EntityRelationshipTailID = null; } dbEntityGroup.EntityGroup_Relationship.Add(db); } if (dbEntityGroup.ID == 0) { projectContext.EntityGroup.Add(dbEntityGroup); } projectContext.SaveChanges(); return(dbEntityGroup.ID); } }
private void SetNewItem() { Message = new EntityGroupDTO(); ShowMessage(); }
//private void Col7_SearchFilterChanged(object sender, SearchFilterArg e) //{ // if (!string.IsNullOrEmpty(e.SingleFilterValue)) // { // if (e.FilerBySelectedValue) // { // var id = Convert.ToInt32(e.SingleFilterValue); // if (id > 0) // { // var relatoinship = bizRelationship.GetRelationship(id); // e.ResultItemsSource = new List<RelationshipDTO> { relatoinship }; // } // else // e.ResultItemsSource = null; // } // else // { // e.ResultItemsSource = bizRelationship.GetRelationships1(EntityID); // } // } // else if (e.Filters.Count > 0) // { // } //} private void GetEntityGroup(int entityGroupID) { Message = bizEntityGroup.GetEntityGroup(MyProjectManager.GetMyProjectManager.GetRequester(), entityGroupID, true); ShowMessage(); }