public async Task <IActionResult> CreateProduct(string id) { IQueryable <Location> listLocations = _locationDb.GetLocations; ViewBag.Message = listLocations; if (id == null) { return(View(new ViewModelsDataEntry())); } else { var modelDataEntry = new ViewModelsDataEntry(); var product = await _productDb.GetProductById(id); var productTransactions = _productTransactionsDb.GetProductTransactionsByIdProduct(id).ElementAt(_productTransactionsDb.GetProductTransactionsByIdProduct(id).Count - 1); modelDataEntry.IdProduct = product.IdProduct; modelDataEntry.ManufacturedDate = product.ManufacturedDate; modelDataEntry.ExpiredDate = product.ExpiredDate; modelDataEntry.Manufactured = product.Manufactured; modelDataEntry.NameProduct = product.NameProduct; modelDataEntry.DateChecked = DateTime.Today; modelDataEntry.IdLocation = productTransactions.IdLocation; modelDataEntry.Details = product.Details; if (modelDataEntry == null) { return(NotFound()); } return(View(modelDataEntry)); } }
public IActionResult GetListTranByIdProduct(string id) { var listProductTran = _productTranDb.GetProductTransactionsByIdProduct(id).ToList(); if (listProductTran.Count == 0) { listProductTran = new List <ProductTransactions>(); return(Json(listProductTran, new Newtonsoft.Json.JsonSerializerSettings())); } else { return(Json(listProductTran, new Newtonsoft.Json.JsonSerializerSettings())); } }