Example #1
0
        public void AddNewHardDrive(AddHardDriveBindingModel ahdbm)
        {
            HardDrive hardDrive = Mapper.Instance.Map <HardDrive>(ahdbm);

            this.Context.HardDrives.Add(hardDrive);
            this.Context.SaveChanges();
        }
        public ActionResult FilterHardDrives(AddHardDriveBindingModel ahbm, string priceRange, string orderType, string productName = "")
        {
            var priceMinMax = GetPriceRangeMinMaxNumbers(priceRange);
            var client      = new HttpClient();
            var response    = client.GetAsync($"http://localhost:15778/api/products/harddrives?driveBrand={ahbm.DriveBrand.ToString("G")}&driveType={ahbm.DriveType.ToString("G")}&$filter=substringof('{productName.ToLower()}', tolower(Name)) eq true and Price ge {priceMinMax[0]} and Price le {priceMinMax[1]} and Discount ge {ahbm.Discount} and Capacity ge {ahbm.Capacity}&$orderby={orderType}").Result;
            var products    = response.Content.ReadAsAsync <IEnumerable <HardDrive> >().Result;

            return(this.PartialView("_GeneralProductViewPartial", this._service.GetGeneralProductPageViewModels(products.ToList())));
        }
Example #3
0
 public ActionResult AddHardDrive(AddHardDriveBindingModel ahdbm)
 {
     if (!ModelState.IsValid)
     {
         ModelState.AddModelError("", "Hard Drive Capacity should be between 80 and 10000");
         return(RedirectToAction("AddProduct"));
     }
     this._service.AddNewHardDrive(ahdbm);
     return(RedirectToAction("Products"));
 }