예제 #1
0
        public Prod_Product_Detail_Model Get_Product_Detail(int productId)
        {
            DataSet DS = _prodDal.Get_Product_Detail(productId);

            Prod_Product_Detail_Model _viewModel = new Prod_Product_Detail_Model();

            if (DS != null && DS.Tables[0] != null)
            {
                if (DS.Tables[0].Rows.Count > 0)
                {
                    var _listModel = (from p in DS.Tables[0].AsEnumerable()
                                      select new Prod_Product_Detail_Model
                    {
                        ProductId = p.Field <int>("ProductID"),
                        ProductName = p.Field <string>("ProductName"),
                        Dosage = p.Field <string>("DosageDescription"),
                        Category = new GenericModel {
                            Id = p.Field <int>("CategoryID"), Name = p.Field <string>("CategoryName")
                        },
                        SubCategory = new GenericModel {
                            Id = p.Field <int>("SubCategoryID"), Name = p.Field <string>("SubCategoryName")
                        },
                        TechnicalName = new GenericModel {
                            Id = p.Field <int>("TechNameID"), Name = p.Field <string>("TechnicalName")
                        },
                        Brand = new GenericModel {
                            Id = p.Field <int>("BrandID"), Name = p.Field <string>("BrandName")
                        },
                        Company = new GenericModel {
                            Id = p.Field <int>("CompanyID"), Name = p.Field <string>("OrganisationName")
                        },
                        PackageType = new GenericModel {
                            Id = p.Field <int>("PckTypeID"), Name = p.Field <string>("PckName")
                        },
                        Quality = new GenericModel {
                            Id = p.Field <int>("QualityID"), Name = p.Field <string>("QualityName")
                        }
                    }).FirstOrDefault();

                    var pkglist = (from q in DS.Tables[1].AsEnumerable()
                                   select new Prod_Package
                    {
                        PackageId = q.Field <int>("PackageID"),
                        Qty = q.Field <decimal>("Amount"),
                        Unit = new GenericModel {
                            Id = q.Field <int>("UnitID"), Name = q.Field <string>("UnitName")
                        },
                        MRP = q.Field <decimal>("MRP"),
                    }).ToList();

                    _listModel.Packahes = pkglist;

                    _viewModel = _listModel;
                }
            }

            return(_viewModel);
        }
        public Prod_Product_Detail_Model Get_Product_Detail(string apiKey, int productId)
        {
            Prod_Product_Detail_Model model = new Prod_Product_Detail_Model();

            if (apiKey == ConfigurationManager.AppSettings["productkey"])
            {
                try
                {
                    model = _pbal.Get_Product_Detail(productId);
                }
                catch (Exception ex)
                {
                    LogBal.ErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, 0);
                }
            }
            return(model);
        }