public async Task <ProductSerializer> GetProductById(int productId, int langualeId) { var product = await _context.Products.FindAsync(productId); var productTranslation = await _context.ProductTranslations .FirstOrDefaultAsync( x => x.productId == productId && x.languageId == langualeId); var productSerializer = new ProductSerializer() { id = product.id, name = productTranslation != null ? productTranslation.name : null, languageId = productTranslation.languageId, brief = productTranslation != null ? productTranslation.brief : null, title = productTranslation != null ? productTranslation.title : null, originalPrice = product.originalPrice, price = product.price, slug = productTranslation != null ? productTranslation.slug : null, inventory = product.inventory, viewCount = product.viewCount }; return(productSerializer); }
void handle(string res) { if (string.IsNullOrEmpty(res)) { if (callback != null) { callback(false); } return; } JsonData jd = JsonMapper.ToObject(res); if (jd.Contains(Param.SCENE)) { List <Scene> updateList; List <Scene> deleteList; SceneSerializer.ToObjects(jd[Param.SCENE].ToJson(), out updateList, out deleteList); if (updateList != null && updateList.Count != 0) { LogicController.ReplaceScenesIgnoreFavourite(updateList); } if (deleteList != null && deleteList.Count != 0) { LogicController.DeleteScenes(deleteList); } } if (jd.Contains(Param.PRODUCT)) { List <Product> updateList; List <Product> deleteList; ProductSerializer.ToObjects(jd[Param.PRODUCT].ToJson(), out updateList, out deleteList); if (updateList != null && updateList.Count != 0) { LogicController.ReplaceProducts(updateList); } if (deleteList != null && deleteList.Count != 0) { LogicController.DeleteProducts(deleteList); } } if (jd.Contains(Param.PICTURE)) { List <Picture> list = PictureSerializer.ToObjects(jd[Param.PICTURE].ToJson()); if (list != null && list.Count != 0) { LogicController.ReplacePictures(list); } } if (jd.Contains(Param.ASSET)) { List <Asset> list = AssetSerializer.ToObjects(jd[Param.ASSET].ToJson()); if (list != null && list.Count != 0) { LogicController.ReplaceAssets(list); } } if (callback != null) { callback(true); } }