Esempio n. 1
0
        static List <SupplierPpeType> extractSupplierPpeType(SuppliesPost post)
        {
            List <SupplierPpeType> ppeList = new List <SupplierPpeType>();

            foreach (string ppe in post.PpeTypes)
            {
                SupplierPpeType supplyPpe = new SupplierPpeType();

                if (Enum.TryParse(ppe, out PpeTypes ppeType))
                {
                    supplyPpe.PpeTypeId = (byte)ppeType;

                    if (ppeType == PpeTypes.Other)
                    {
                        supplyPpe.PpeTypeOther = post.OtherPpeTypes; //only add other if ppetype is other
                    }
                }
                else //fallback in case some ppe doesn't match our enums
                {
                    supplyPpe.PpeTypeId    = (int)PpeTypes.Other;
                    supplyPpe.PpeTypeOther = post.OtherPpeTypes;
                }

                ppeList.Add(supplyPpe);
            }

            return(ppeList);
        }
Esempio n. 2
0
        static void extractSupplierType(SuppliesPost post, Supplier newSupplier)
        {
            if (Enum.TryParse(post.OrganisationType, out SupplierTypes supplierType))
            {
                newSupplier.SupplierTypeId = (int)supplierType;
            }
            else //fall back is orgtype id isn't found
            {
                newSupplier.SupplierTypeId = (int)SupplierTypes.Other;
            }

            newSupplier.SupplierTypeOther = post.OtherOrganisationType;
        }