示例#1
0
        public HttpResponseMessage ViewCategory(HttpRequestMessage req, RP_ViewCategory rpViewCategory)
        {
            if (rpViewCategory != null)
            {
                RM_ViewCategory rmViewCategory = new RM_ViewCategory();
                List<RPR_ViewCategory> rprViewCategory = rmViewCategory.ViewCategory(rpViewCategory);

                if (rmViewCategory._IsSuccess)
                    return req.CreateResponse<List<RPR_ViewCategory>>(HttpStatusCode.Created, rprViewCategory);

                return req.CreateErrorResponse(HttpStatusCode.InternalServerError, "ServerError");
            }

            return req.CreateErrorResponse(HttpStatusCode.BadRequest, "Bad Request");
        }
示例#2
0
        public List<RPR_ViewCategory> ViewCategory(RP_ViewCategory rpViewCategory)
        {
            this.SpName = "DigitalMenu_ViewCat"; //Sp Name
            _IsSuccess = true;
            try
            {
                SqlParameter[] param = new SqlParameter[4];
                param[0] = new SqlParameter("@CusId", int.Parse(rpViewCategory.CusId));
                param[1] = new SqlParameter("@RestId", int.Parse(rpViewCategory.RestId));
                param[2] = new SqlParameter("@key", rpViewCategory.key);
                param[3] = new SqlParameter("@isHappyHourTime", rpViewCategory.isHappyHourTime);

                ds = db.GetDataSet(this.SpName, param);

                if (ds != null && ds.Tables.Count > 0)
                {
                    // used data set and data table

                    DataTable Tables = new DataTable("category");
                    Tables.Columns.Add("CategoryName");
                    Tables.Columns.Add("CategoryDesc");
                    Tables.Columns.Add("CategoryImage");

                    // loop through category
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        string catName = "" + dr["CategoryName"].ToString();
                        string catDesc = "" + dr["CategoryDesc"].ToString();

                        //  if (catName != "" && catName != "Happy Hour") //chk catName
                        if (catName != "") //chk catName
                        {
                            string absolutePath = @"F:\www\Pabulum\img\category\";
                            //string absolutePath = @"C:\inetpub\PabulumLatest\img\category\";
                            absolutePath += catName + ".txt";
                            string catImages = "";
                            if (File.Exists(absolutePath))
                            {
                                catImages = File.ReadAllText(absolutePath);
                            }
                            Tables.Rows.Add(catName, catDesc, catImages);
                        }
                        else
                        {
                            Tables.Rows.Add(catName, catDesc, "");

                        }
                    }  // foreach end

                    DataSet dsNew = new DataSet("dataset");
                    dsNew.Tables.Add(Tables);
                    rprViewCategory = SerializeData.SerializeMultiValue<RPR_ViewCategory>(dsNew.Tables[0]);
                }

            }
            catch (Exception ex)
            {
                _IsSuccess = false;
                Logger.WriteLog(LogLevelL4N.ERROR, " View Category | Exception : " + ex.Message);
            }
            return rprViewCategory;
        }