public ApiMessage CreateStoreHouse() { ApiMessage message = new ApiMessage(); 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; StockManager stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); try { BStoreHouse house = new BStoreHouse(); house.Name = request["name"]; house.Address = request["address"]; house.Phone = request["phone"]; house.IsDefault = false; if (!string.IsNullOrEmpty(request["isdefault"])) { if (request["isdefault"] == "1") { house.IsDefault = true; } } stockManager.CreateStoreHouse(house); message.Status = "ok"; message.Message = "创建成功"; } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { message.Status = "failed"; message.Message = "未知错误"; } return(message); }