public void AddNewGraphicCard(AddGraphicCardBindingModel agcbm) { GraphicCard graphicCard = Mapper.Instance.Map <GraphicCard>(agcbm); this.Context.GraphicCards.Add(graphicCard); this.Context.SaveChanges(); }
public ActionResult FilterGraphicCards(AddGraphicCardBindingModel agcbm, string priceRange, string orderType, string productName = "") { var priceMinMax = GetPriceRangeMinMaxNumbers(priceRange); var client = new HttpClient(); var response = client.GetAsync($"http://localhost:15778/api/products/graphiccards?memoryType={agcbm.MemoryType.ToString("G")}&brand={agcbm.Brand.ToString("G")}&manufacturer={agcbm.Manufacturer.ToString("G")}&$filter=substringof('{productName.ToLower()}', tolower(Name)) eq true and Price ge {priceMinMax[0]} and Price le {priceMinMax[1]} and Discount ge {agcbm.Discount} and Memory ge {agcbm.Memory}&$orderby={orderType}").Result; var products = response.Content.ReadAsAsync <IEnumerable <GraphicCard> >().Result; return(this.PartialView("_GeneralProductViewPartial", this._service.GetGeneralProductPageViewModels(products.ToList()))); }
public ActionResult AddGraphicCard(AddGraphicCardBindingModel agcbm) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Hard Drive Capacity should be between 80 and 10000"); return(RedirectToAction("AddProduct")); } this._service.AddNewGraphicCard(agcbm); return(RedirectToAction("Products")); }