private string GetPrimaryObjectTypeString(PrimaryObjectType type) { switch (type) { case PrimaryObjectType.Strain: return("strains"); case PrimaryObjectType.Flower: return("flowers"); case PrimaryObjectType.Extract: return("extracts"); case PrimaryObjectType.Edible: return("edibles"); case PrimaryObjectType.Product: return("products"); case PrimaryObjectType.Producer: return("producers"); case PrimaryObjectType.Dispensary: return("dispensaries"); case PrimaryObjectType.SeedCompany: return("seed-companies"); default: return("UNKNOWN OBJECT"); } }
public UCPC(string ucpc, PrimaryObjectType type) { if (ucpc.Length == 25) { var regex = new Regex("^[a-zA-Z0-9]*$"); if (regex.IsMatch(ucpc)) { Code = ucpc; Type = type; ParseCode(ucpc, type); if (!VerifyObjectType(type)) { HasErrors = true; } } else { throw new Exception("UCPC code must be Alphanumeric."); } } else { throw new Exception("UCPC code must be 25 characters in length. (Alphanumeric)"); } }
private void ParseCode(string ucpc, PrimaryObjectType type) { SeedCompanyCode = PadPartialCode(PrimaryObjectType.SeedCompany, ucpc.Substring(0, 5)); StrainCode = PadPartialCode(PrimaryObjectType.Strain, ucpc.Substring(5, 5)); ProducerCode = PadPartialCode(PrimaryObjectType.Producer, ucpc.Substring(10, 5)); ProductCode = PadPartialCode(PrimaryObjectType.Product, ucpc.Substring(15, 5)); BatchCode = PadPartialCode(PrimaryObjectType.Batch, ucpc.Substring(20, 5)); }
public void GenerateCannabisReportsUrl(PrimaryObjectType type) { var sb = new StringBuilder(); sb.Append(GetBaseUrl()); sb.Append(GetPrimaryObjectTypeString(type)); URL = sb.ToString(); }
public void GenerateCannabisReportsUrl(PrimaryObjectType primaryType, SecondaryObjectType secondaryType) { var sb = new StringBuilder(); sb.Append(GetBaseUrl()); sb.Append(GetPrimaryObjectTypeString(primaryType)); sb.Append("/type/"); sb.Append(GetSecondaryObjectTypeString(secondaryType)); URL = sb.ToString(); }
public void GenerateCannabisReportsUrl(PrimaryObjectType type, string query) { GenerateCannabisReportsUrl(type); var sb = new StringBuilder(); sb.Append(URL); sb.Append("/search/"); sb.Append(query); URL = sb.ToString(); }
private bool VerifyObjectType(PrimaryObjectType type) { switch (type) { case PrimaryObjectType.Strain: if (StrainCode == "0000000000000000000000000") { return(false); } break; case PrimaryObjectType.Product: if (ProductCode == "0000000000000000000000000") { return(false); } break; case PrimaryObjectType.Producer: if (ProducerCode == "0000000000000000000000000") { return(false); } break; case PrimaryObjectType.SeedCompany: if (SeedCompanyCode == "0000000000000000000000000") { return(false); } break; case PrimaryObjectType.Batch: if (BatchCode == "0000000000000000000000000") { return(false); } break; default: return(false); } return(true); }
private string PadPartialCode(PrimaryObjectType type, string partialUCPC) { switch (type) { case PrimaryObjectType.Strain: return("00000" + partialUCPC.PadRight(20, '0')); case PrimaryObjectType.Product: return("000000000000000" + partialUCPC.PadRight(10, '0')); case PrimaryObjectType.Producer: return("0000000000" + partialUCPC.PadRight(15, '0')); case PrimaryObjectType.SeedCompany: return(partialUCPC.PadRight(25, '0')); case PrimaryObjectType.Batch: return(partialUCPC.PadLeft(25, '0')); } return(""); }
public void GenerateCannabisReportsUrl(string state, string city, string slug, PrimaryObjectType type) { GenerateCannabisReportsUrl(state, city, slug); var sb = new StringBuilder(); sb.Append(URL); sb.Append("/"); sb.Append(GetPrimaryObjectTypeString(type)); URL = sb.ToString(); }