Exemplo n.º 1
0
        public IEnumerable <UserGroup> Get(int page)
        {
            var httpCookie = HttpContext.Current.Request.Cookies["Retailer"];

            if (httpCookie == null)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NonAuthoritativeInformation));
            }
            var tooken = httpCookie.Value;

            try
            {
                return(UserGroupBll.Get(page, 10));
            }
            catch
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }
        }
Exemplo n.º 2
0
        // GET api/usergroupapi/5
        public CUserGroup Get(int id)
        {
            var user = (CSign)HttpContext.Current.Session[ConfigurationManager.AppSettings["AuthSaveKey"]];

            if (user == null)
            {
                throw new HttpResponseException(new SiginFailureMessage());
            }
            using (
                var dal =
                    DalBuilder.CreateDal(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, 0)
                )
            {
                CUserGroup userGroup;
                try
                {
                    dal.Open();
                    userGroup = UserGroupBll.Get(dal, id);
                    dal.Close();
                }
                catch (Exception ex)
                {
                    LogBll.Write(dal, new CLog
                    {
                        LogUser    = string.Format("{0}-{1}", user.UserCode, user.UserName),
                        LogContent = string.Format("{0}#{1}", "UserGroup.List", ex.Message),
                        LogType    = LogType.系统异常
                    });
                    throw new HttpResponseException(new SystemExceptionMessage());
                }
                if (userGroup == null)
                {
                    throw new HttpResponseException(new DataNotFoundMessage());
                }
                return(userGroup);
            }
        }