static void extractOrgType(NeedsPost post, Need newNeed) { if (Enum.TryParse(post.OrganisationType, out OrgTypes orgType)) //N.B. won't work { newNeed.OrgTypeId = (int)orgType; } else //fall back is orgtype id isn't found { Debugger.Break(); newNeed.OrgTypeId = (int)OrgTypes.Other; } newNeed.OrgTypeOther = post.OtherOrganisationType; }
static List <NeedPpeType> extractNeedsPpeType(NeedsPost post, Need newNeed) { List <NeedPpeType> ppeList = new List <NeedPpeType>(); foreach (string ppe in post.PpeTypes) { NeedPpeType needsPpe = new NeedPpeType(); if (Enum.TryParse(ppe, out PpeTypes ppeType)) //N.B. won't work { needsPpe.PpeTypeId = (byte)ppeType; if (ppeType == PpeTypes.FFP1RespiratorMasks) //only add the daily shortage if ppe is ffp1 { needsPpe.DailyShortage = post.FFP1DailyShortage; needsPpe.DailyShortageForWhom = post.FFP1DailyDetails; } if (ppeType == PpeTypes.Other) { Debugger.Break(); needsPpe.PpeTypeOther = post.OtherPpeTypes; //only add other if ppetype is other } } else //fallback in case some ppe doesn't match our enums { Debugger.Break(); needsPpe.PpeTypeId = (int)PpeTypes.Other; needsPpe.PpeTypeOther = post.OtherPpeTypes; } needsPpe.StatusId = (int)PpeStatus.New; ppeList.Add(needsPpe); } return(ppeList); }