Example #1
0
        public int GetDetail(long ID, out DisplayCategory_model Model)
        {
            int returnCode = (int)Common.ReturnCode.Succeed;

            Model = new DisplayCategory_model();
            try
            {
                if (ID != 0)
                {
                    string sql = "SELECT cate.`id`, cate_parent.`name` parent_name, cate.`code`, cate.`name`, cate.`description`";
                    sql  += " FROM product_category cate LEFT JOIN(SELECT `id`, `name` FROM `product_category`) cate_parent";
                    sql  += " ON cate.`parent_id` = cate_parent.id WHERE cate.`id` = @id";
                    Model = db.Query <DisplayCategory_model>(sql, new { id = ID }).SingleOrDefault();
                }
            }
            catch (Exception)
            {
                returnCode = (int)Common.ReturnCode.UnSuccess;
            }

            return(returnCode);
        }
        public ActionResult View(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                TempData["Error"] = "Data has already been deleted by other user!";
                return(RedirectToAction("Index"));
            }

            DisplayCategory_model Model = new DisplayCategory_model();
            int returnCode = _categoryBL.GetDetail(long.Parse(id), out Model);

            if (Model == null)
            {
                TempData["Error"] = "Data has already been deleted by other user!";
                return(RedirectToAction("Index"));
            }
            if (!((int)Common.ReturnCode.Succeed == returnCode))
            {
                Model = new DisplayCategory_model();
            }

            return(View(Model));
        }
 public int GetDetail(long ID, out DisplayCategory_model model)
 {
     return(category_bll.GetDetail(ID, out model));
 }