public async Task<ActionResult> ProductList() { try { ParseQuery<ParseObject> query = ParseObject.GetQuery("Product"); IEnumerable<ParseObject> products = await query.FindAsync(); List<ProductViewModel> _products = new List<ProductViewModel>(); foreach (ParseObject p in products) { ProductViewModel product = new ProductViewModel(p); // Get specification from product Specification sp = new Specification(await p.Get<ParseObject>("specification").FetchIfNeededAsync()); // Add specification into product model product.setSpecification(sp); _products.Add(product); } return View(_products); } catch (ParseException) { return View(); } }
public async Task<ActionResult> EditProduct(string id) { try { ParseQuery<ParseObject> query = ParseObject.GetQuery("Product"); ParseObject product = await query.GetAsync(id); ProductViewModel _product = new ProductViewModel(product); Specification _specification = new Specification(await product.Get<ParseObject>("specification").FetchIfNeededAsync()); ProductSpecificationModel model = new ProductSpecificationModel(); model.ProductModel = _product; model.Specification = _specification; return View(model); } catch (ParseException) { return View(); } }
public void setSpecification(Specification spec) { specification = new Specification(); specification.specificationId = spec.specificationId; specification.screen = spec.screen; specification.frontCamera = spec.frontCamera; specification.backCamera = spec.backCamera; specification.os = spec.os; specification.chipset = spec.chipset; specification.cpu = spec.cpu; specification.ram = spec.ram; specification.internalStorage = spec.internalStorage; specification.sdcard = spec.sdcard; specification.simNumber = spec.simNumber; specification.batery = spec.batery; specification.connection = spec.connection; }