public HttpResponseMessage GetModel() { var lensAttributes = this.GetAllLensAttributes(); var lensTypes = this.GetAllLensTypes(); var lensMaterials = this.GetAllLensMaterials(); var lensStyles = this.GetAllLensStyles(); var vm = new EyeglassSetupVm { LensAttributes = lensAttributes.ToKeyValuePairs(), LensTypes = lensTypes.ToKeyValuePairs(), LensMaterials = lensMaterials.ToKeyValuePairs(), LensStyles = lensStyles.ToKeyValuePairs() }; return(this.Request.CreateResponse(HttpStatusCode.OK, vm)); }
public HttpResponseMessage GetEyeglassLensItems(string officeNumber, string lensAttribute, string lensType, string lensMaterial, string lensStyle, string searchText, bool activeOnly) { bool?active = null; var items = new List <EyeglassLensSetup>(); var itemGroups = new List <Model.Admin.Item>(); var lensPricingItemTypes = new EyeglassSetupVm(); int?lensAttributeId = null; if (!string.IsNullOrEmpty(lensAttribute)) { lensAttributeId = Convert.ToInt32(lensAttribute); } var flexiblePricing = this.eyeglassLensIt2Manager.GetFlexiblePricingAttribute(lensAttributeId); int?lensTypeId = null; if (!string.IsNullOrEmpty(lensType)) { lensTypeId = Convert.ToInt32(lensType); } int?lensMaterialId = null; if (!string.IsNullOrEmpty(lensMaterial)) { lensMaterialId = Convert.ToInt32(lensMaterial); } int?lensStyleId = null; if (!string.IsNullOrEmpty(lensStyle)) { lensStyleId = Convert.ToInt32(lensStyle); } if (activeOnly) { active = true; } itemGroups = this.eyeglassLensIt2Manager.GetItemGroups(lensAttributeId.GetValueOrDefault()).ToList(); items = this.eyeglassLensIt2Manager.GetEyeglassLensItems(officeNumber, lensAttributeId, lensTypeId, lensMaterialId, lensStyleId, active.GetValueOrDefault()); if (items.Count > MaxItems && !string.IsNullOrEmpty(searchText)) { items = this.SearchItems(items, searchText); } if (items.Count > MaxItems) { return(this.Request.CreateResponse(HttpStatusCode.RequestedRangeNotSatisfiable, items.Count.ToString(CultureInfo.InvariantCulture))); } return(this.Request.CreateResponse( HttpStatusCode.OK, new { EyeglassLensSetupItems = items, ItemGroups = itemGroups.Select(ItemGroupVm.FromItem), lensPricingItemTypes = flexiblePricing })); }