Skip to content

Commit

Permalink
Add missing relationships in user's view closes BEXIS2#708
Browse files Browse the repository at this point in the history
  • Loading branch information
geofranzi committed Feb 16, 2021
1 parent 7888678 commit 4407798
Showing 1 changed file with 40 additions and 0 deletions.
Expand Up @@ -184,6 +184,7 @@ public ActionResult Edit(bool relationTabAsDefault = false)
else
model.EndDate = party.EndDate;
model.Name = party.Name;
model.PartyRelationships = getPartyRelationships(party.Id);
ViewBag.RelationTabAsDefault = false;
ViewBag.Title = "Edit party";

Expand Down Expand Up @@ -352,5 +353,44 @@ public JsonResult ValidateRelationships(int partyId)
{
return Json(Helpers.Helper.ValidateRelationships(partyId));
}

// copied from PartyController.cs
/// <summary>
/// get all party releationships without system releationships like to entites like dataset
/// </summary>
/// <param name="partyId"></param>
/// <returns></returns>
private List<PartyRelationshipModel> getPartyRelationships(long partyId)
{
using (var partyManager = new PartyManager())
{
var temp = new List<PartyRelationshipModel>();

var rList = partyManager.PartyRelationshipRepository.Get
(item => (item.SourceParty.Id == partyId || item.TargetParty.Id == partyId)
&& (item.TargetParty.PartyType.SystemType == false && item.SourceParty.PartyType.SystemType == false)).ToList();

partyManager.PartyRelationshipRepository.LoadIfNot(rList.Select(r => r.TargetParty));
partyManager.PartyRelationshipRepository.LoadIfNot(rList.Select(r => r.TargetParty.PartyType));

foreach (var r in rList)
{
temp.Add(new PartyRelationshipModel()
{
Id = r.Id,
Title = r.Title,
Description = r.Description,
SourceName = r.SourceParty.Name,
TargetName = r.TargetParty.Name,
StartDate = r.StartDate,
EndDate = r.EndDate
});
}

return temp;
}
}


}
}

0 comments on commit 4407798

Please sign in to comment.