public void AddNewProcessor(AddProcessorBindingModel apbm) { Processor processor = Mapper.Instance.Map <Processor>(apbm); this.Context.Processors.Add(processor); this.Context.SaveChanges(); }
public ActionResult FilterProcessors(AddProcessorBindingModel apbm, string priceRange, string orderType, string productName = "") { var priceMinMax = GetPriceRangeMinMaxNumbers(priceRange); var client = new HttpClient(); var response = client.GetAsync($"http://localhost:15778/api/products/processors?brand={apbm.Brand.ToString("G")}&series={apbm.Series.ToString("G")}&cores={apbm.Cores.ToString("G")}&$filter=substringof('{productName.ToLower()}', tolower(Name)) eq true and Price ge {priceMinMax[0]} and Price le {priceMinMax[1]} and Discount ge {apbm.Discount} and Cache ge {apbm.Cache} and ProcessorSpeed ge {apbm.ProcessorSpeed}&$orderby={orderType}").Result; var products = response.Content.ReadAsAsync <IEnumerable <Processor> >().Result; return(this.PartialView("_GeneralProductViewPartial", this._service.GetGeneralProductPageViewModels(products.ToList()))); }
public ActionResult AddProcessor(AddProcessorBindingModel apbm) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Cache should be between 1 and 32 Mb and clock speed be between 1 and 16 Ghz"); return(RedirectToAction("AddProduct")); } this._service.AddNewProcessor(apbm); return(RedirectToAction("Products")); }