public IEnumerable<PD_TransitionDTO> GetAllTransitions(int id, int sid)
{
PD_Subject i = _db.PD_Subjects.Find(id, sid);
List<PD_TransitionDTO> t = new List<PD_TransitionDTO>();
foreach (var tr in i.Transitions)
{
var temp = new PD_TransitionDTO() { Id = tr.Id, Source = tr.Source, Target = tr.Target, Type = tr.Type, LabelPosition = tr.LabelPosition };
if (tr.Type == PD_TransitionTypes.RegularTransition)
{
temp.Label = ((PD_RegularTransition)tr).Name;
}
if (tr.Type == PD_TransitionTypes.ReceiveTransition)
{
try
{
PD_Message m = _db.PD_Messages.Find(id, ((PD_ReceiveTransition)tr).Message);
PD_MessageType mt = m.PD_MessageType;
PD_Subject s = _db.PD_Subjects.Find(id, m.From);
temp.Label = s.Name + "|" + mt.Name;
}
catch (Exception e)
{
temp.Label = "Receive";
}
}
if (tr.Type == PD_TransitionTypes.TimeoutTransition)
{
temp.Label = ((PD_TimeoutTransition)tr).TimeSpan;
}
if (temp.Label == null)
temp.Label = "EMPTY";
t.Add(temp);
}
return t.ToArray();
}