Example #1
0
 public JsonResult GetByIdInfo(int id)
 {
     try
     {
         var product = productBLL.GetById(id);
         var x       = new ProductViewModel();
         if (product != null)
         {
             x.ID    = product.ID;
             x.Name  = product.Name;
             x.Image = product.Image;
             var lstImage = Tools.LoadMoreImages(product.MoreImages);
             x.Description  = string.IsNullOrEmpty(product.Description) ? "Không có" : product.Description;
             x.Frame        = product.Frame;
             x.Rims         = product.Rims;
             x.Tires        = product.Tires;
             x.Weight       = product.Weight;
             x.Weightlimit  = product.Weightlimit;
             x.StrPrice     = string.Format("{0:#,##0}", product.Price) + " VNĐ";
             x.StrPromotion = product.Promotion > 0 ? Convert.ToString(product.Promotion) + "%" : "Không có";
             x.Quantity     = product.Quantity;
             x.StrCategory  = productCategoryBLL.GetName(product.CategoryID);
             x.StrSupplier  = supplierBLL.GetName(product.SupplierID);
             x.CreatedBy    = string.IsNullOrEmpty(product.CreatedBy) ? "Không có" : product.CreatedBy;
             x.CreatedDate  = product.CreatedDate.ToString();
             x.ModifiedBy   = string.IsNullOrEmpty(product.ModifiedBy) ? "Không có" : product.ModifiedBy;
             x.ModifiedDate = string.IsNullOrEmpty(product.ModifiedDate.ToString()) ? "Không có" : product.ModifiedDate.ToString();
             x.ViewCount    = product.ViewCount;
             return(Json(new
             {
                 obj = x,
                 lstImage = lstImage
             }, JsonRequestBehavior.AllowGet));
         }
         return(Json(null, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json(null, JsonRequestBehavior.AllowGet));
     }
 }