public Guid GetLieId(string faceLieAdjustmentC) { if (!ClubLies.Any()) { ClubLies = _repository.Query <ClubLie>().ToList(); } var lie = ClubLies.FirstOrDefault(x => x.Value.ToLower() == faceLieAdjustmentC.ToLower()); if (lie == null) { lie = new ClubLie { Value = faceLieAdjustmentC, Created = DateTime.UtcNow }; _repository.Save(lie); ClubLies.Add(lie); } if (lie.Id != null) { return(lie.Id.Value); } return(Guid.Empty); }
private void LoadStaticFromApis() { var response = PostJson("https://my.taylormadegolf.com/myFittingExp/api/authentication?j_username=tmagitadmin&j_password=AtuS3VhLw2&remember-me=true&submit=Login", new { }); var csrfToken = response.Cookies["CSRF-TOKEN"].Value; var jSessionId = response.Cookies["JSESSIONID"].Value; // flex var ironFlex = GetJson("https://my.taylormadegolf.com/myFittingExp/api/lookups_by_type/Profile_Current_Shaft_Flex", response.Cookies); var flexString = GetDataString(ironFlex); var flexIronObjects = JsonConvert.DeserializeAnonymousType(flexString, loogUpObject); var ironCategoryId = _staticTableHelper.GetCategoryId("Iron"); var driverCategoryId = _staticTableHelper.GetCategoryId("Driver"); var fairwayCategoryId = _staticTableHelper.GetCategoryId("Fairway"); var rescueCategoryId = _staticTableHelper.GetCategoryId("Rescue"); var wedgeCategoryId = _staticTableHelper.GetCategoryId("Wedge"); foreach (var item in flexIronObjects) { var i = new ClubShaftFlex(); i.Value = item.lookupValue; i.SortOrder = item.sortOrder; _repository.SaveQueue(i); } //drive loft var driverLoft = GetJson("https://my.taylormadegolf.com/myFittingExp/api/lookups_by_type/Industry_Driver_Loft", response.Cookies); var driverLoftString = GetDataString(driverLoft); var driverLoftObjects = JsonConvert.DeserializeAnonymousType(driverLoftString, loogUpObject); foreach (var item in driverLoftObjects) { var i = new ClubLoft(); i.Value = item.lookupValue; i.SortOrder = item.sortOrder; i.ClubCategoryId = driverCategoryId; _repository.SaveQueue(i); } //fw loft var fwLoft = GetJson("https://my.taylormadegolf.com/myFittingExp/api/lookups_by_type/Industry_FW_Loft", response.Cookies); var fwLoftString = GetDataString(fwLoft); var fwObjects = JsonConvert.DeserializeAnonymousType(fwLoftString, loogUpObject); foreach (var item in fwObjects) { var i = new ClubLoft(); i.Value = item.lookupValue; i.SortOrder = item.sortOrder; i.ClubCategoryId = fairwayCategoryId; _repository.SaveQueue(i); } //fw loft var RescueLoft = GetJson("https://my.taylormadegolf.com/myFittingExp/api/lookups_by_type/Industry_Rescue_Loft", response.Cookies); var RescueLoftString = GetDataString(RescueLoft); var RescueObjects = JsonConvert.DeserializeAnonymousType(RescueLoftString, loogUpObject); foreach (var item in RescueObjects) { var i = new ClubLoft(); i.Value = item.lookupValue; i.SortOrder = item.sortOrder; i.ClubCategoryId = rescueCategoryId; _repository.SaveQueue(i); } //iron loft var ironLoft = GetJson("https://my.taylormadegolf.com/myFittingExp/api/lookups_by_type/Industry_Iron_Loft", response.Cookies); var ironLoftString = GetDataString(ironLoft); var ironObjects = JsonConvert.DeserializeAnonymousType(ironLoftString, loogUpObject); foreach (var item in ironObjects) { var i = new ClubLoft(); i.Value = item.lookupValue; i.SortOrder = item.sortOrder; i.ClubCategoryId = ironCategoryId; _repository.SaveQueue(i); } //iron loft var ironLoft12 = GetJson("https://my.taylormadegolf.com/myFittingExp/api/lookups_by_type/WITB_Wedge_Loft", response.Cookies); var ironLoftString12 = GetDataString(ironLoft12); var ironObjects12 = JsonConvert.DeserializeAnonymousType(ironLoftString12, loogUpObject); foreach (var item in ironObjects12) { var i = new ClubLoft(); i.Value = item.lookupValue; i.SortOrder = item.sortOrder; i.ClubCategoryId = wedgeCategoryId; _repository.SaveQueue(i); } //Club shaflength var shaflength = GetJson("https://my.taylormadegolf.com/myFittingExp/api/lookups_by_type/Profile_Current_Iron_Length", response.Cookies); var shaflengthString = GetDataString(shaflength); var shaflengthO = JsonConvert.DeserializeAnonymousType(shaflengthString, loogUpObject); foreach (var item in shaflengthO) { var i = new ClubShaftLength(); i.Value = item.lookupValue; i.SortOrder = item.sortOrder; _repository.SaveQueue(i); } //clubLie var clubLie = GetJson("https://my.taylormadegolf.com/myFittingExp/api/lookups_by_type/Profile_Current_Iron_Lie", response.Cookies); var clubLieString = GetDataString(clubLie); var clubLieStringo = JsonConvert.DeserializeAnonymousType(clubLieString, loogUpObject); foreach (var item in clubLieStringo) { var i = new ClubLie(); i.Value = item.lookupValue; i.SortOrder = item.sortOrder; _repository.SaveQueue(i); } LoadClubCategoryTypes(response.Cookies, ironCategoryId, "WITB_Iron_Head_Loft"); LoadClubCategoryTypes(response.Cookies, fairwayCategoryId, "WITB_FW_Head_Loft"); LoadClubCategoryTypes(response.Cookies, rescueCategoryId, "WITB_Rescue_Head_Loft"); LoadClubCategoryTypes(response.Cookies, wedgeCategoryId, "WITB_Wedge_Head_Loft"); LoadClubLoftAdjustment(response.Cookies); var putterCategoryId = _staticTableHelper.GetCategoryId("Putter"); LoadClubBrands(response.Cookies, 1, driverCategoryId); LoadClubBrands(response.Cookies, 2, ironCategoryId); LoadClubBrands(response.Cookies, 3, fairwayCategoryId); LoadClubBrands(response.Cookies, 4, rescueCategoryId); LoadClubBrands(response.Cookies, 5, putterCategoryId); LoadClubBrands(response.Cookies, 6, wedgeCategoryId); _repository.Save(); }