public ActionResult Index(int id) { var db = new PharmacyEntities(); var model = db.Products.Find(id); var detail = new ProductDetailModel() { id = model.ID, ProductName = model.ProductName, Unit = model.Unit, Price = model.Buy, Category = model.Category.CateName, Barcode = model.Barcode, uuid = System.Guid.NewGuid().ToString() }; return(Json(detail, JsonRequestBehavior.AllowGet)); }
public ActionResult Barcode(string Barcode) { var db = new PharmacyEntities(); var model = db.Products.Where(x => x.Barcode == Barcode).FirstOrDefault(); try { var detail = new ProductDetailModel() { id = model.ID, ProductName = model.ProductName, Unit = model.Unit, Price = model.Buy, Barcode = model.Barcode, uuid = System.Guid.NewGuid().ToString() }; return(Json(detail, JsonRequestBehavior.AllowGet)); } catch (Exception) { var detail = new ProductDetailModel(); return(Json(detail, JsonRequestBehavior.AllowGet)); } }