public ActionResult Detail(string id) { if (string.IsNullOrEmpty(id)) { return Redirect("/Home/Error?message="+HttpUtility.UrlEncode("请输入正确的产品ID")); } int product_id = 0; int.TryParse(id, out product_id); if (product_id == 0) { return Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("请输入正确的产品ID")); } BProduct product = null; string user_id = HttpContext.User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; Shop MainShop = userMgr.Main_Shop; ProductManager pdtManager = new ProductManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); try { product = pdtManager.GetProductFullInfo(product_id); } catch (KMJXCException kex) { return Redirect("/Home/Error?message=" + HttpUtility.UrlEncode(kex.Message)); } catch { return Redirect("/Home/Error?message=" + HttpUtility.UrlEncode("未知错误")); } return View(product); }
public ApiMessage GetFullInfo() { ApiMessage message = new ApiMessage() { Status="ok" }; BProduct product=null; message.Item = product; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ProductManager pdtManager = new ProductManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int product_id = 0; string mall_id = request["mall_id"]; int.TryParse(request["product_id"],out product_id); try { product = pdtManager.GetProductFullInfo(product_id, mall_id); if (product != null) { message.Item = product; } else { message.Status = "ok"; } } catch (KM.JXC.Common.KMException.KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { message.Status = "failed"; message.Message = "未知错误"; } return message; }