Пример #1
0
        public static BaseActionResult CreateHistory(History obj4create)
        {
            string msg;
            if (obj4create == null)
            {
                msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, XiaoluResources.STR_HISTORY) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL);
                return new BaseActionResult(false, msg);
            }

            try
            {
                using (var context = new XiaoluEntities())
                {
                    var repository = new HistoryRepository(context);
                    string newId = Guid.NewGuid().ToString();
                    obj4create.Id = newId;
                    repository.Create(obj4create);
                    context.SaveChanges();
                    msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, obj4create.UserId);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_CREATE_FAIL, obj4create.UserId) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg);
            }
        }
Пример #2
0
        public static BaseActionResult BulkDeleteHistoryByIds(string idsStr)
        {
            string msg;
            string[] idArr = idsStr.Split(',');
            if (idArr.Length == 0)
            {
                msg = XiaoluResources.ERR_MSG_NO_RECORD_FOR_ACTION;
                return new BaseActionResult(false, msg);
            }
            try
            {
                List<History> list4delete = new List<History>();
                foreach (string id in idArr)
                {
                    var obj4delete = GetHistoryById(id);
                    list4delete.Add(obj4delete);
                }

                using (var context = new XiaoluEntities())
                {
                    var repository = new HistoryRepository(context);
                    repository.BulkDelete(list4delete);
                    context.SaveChanges();
                    msg = string.Format(XiaoluResources.MSG_BULK_ACTION_SUCCESS, XiaoluResources.STR_HISTORY, idArr.Length);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_BULK_ACTION_FAIL, XiaoluResources.STR_DELETE, idArr.Length) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg, e);
            }
        }
Пример #3
0
        public static int CountHistoryByQuery(HistoryQuery query)
        {
            using (var context = new XiaoluEntities())
            {
                var repository = new HistoryRepository(context);

                int count = repository.GetPageCount(item => _isMatch(item, query));
                return count;
            }
        }
        public static int CountUserAccessTokenByQuery(UserAccessTokenQuery query)
        {
            using (var context = new XiaoluEntities())
            {
                var repository = new UserAccessTokenRepository(context);

                int count = repository.GetPageCount(item => _isMatch(item, query));
                return count;
            }
        }
Пример #5
0
        public static BaseActionResult DeleteHistory(History obj4delete)
        {
            using (var context = new XiaoluEntities())
            {
                string msg;
                var repository = new HistoryRepository(context);

                if (obj4delete == null)
                {
                    msg = string.Format(XiaoluResources.MSG_DELETE_SUCCESS, XiaoluResources.STR_HISTORY) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL);
                    return new BaseActionResult(false, msg);
                }
                repository.Delete(obj4delete);
                context.SaveChanges();
                msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, obj4delete.UserId);
                return new BaseActionResult(true, msg);
            }
        }
Пример #6
0
        public static List<History> GetHistoryListByQuery(HistoryQuery query)
        {
            using (var context = new XiaoluEntities())
            {
                var repository = new HistoryRepository(context);

                List<History> historys = repository.GetPageList(item => _isMatch(item, query), item => _orderByKey(item, query), query.OrderByValue, query.Offset, query.Limit);
                return historys;
            }
        }
Пример #7
0
        public static BaseActionResult UpdateUser(User obj4update)
        {
            string msg;
            if (obj4update == null)
            {
                msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, XiaoluResources.STR_USER) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL);
                return new BaseActionResult(false, msg);
            }

            try
            {
                using (var context = new XiaoluEntities())
                {
                    var repository = new UserRepository(context);
                    repository.Update(obj4update);
                    context.SaveChanges();
                    msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, obj4update.Name);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(XiaoluResources.MSG_UPDATE_FAIL, obj4update.Name) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg);
            }
        }
Пример #8
0
        public static List<User> GetUserListByQuery(UserQuery query)
        {
            using (var context = new XiaoluEntities())
            {
                var repository = new UserRepository(context);

                List<User> users = repository.GetPageList(item => _isMatch(item, query), item => _orderByKey(item, query), query.OrderByValue, query.Offset, query.Limit);
                return users;
            }
        }
        public static BaseActionResult DeleteUserAccessToken(UserAccessToken obj4delete)
        {
            using (var context = new XiaoluEntities())
            {
                string msg;
                var repository = new UserAccessTokenRepository(context);

                if (obj4delete == null)
                {
                    msg = string.Format(XiaoluResources.MSG_DELETE_SUCCESS, XiaoluResources.STR_USER_ACCESS_TOKEN) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL);
                    return new BaseActionResult(false, msg);
                }
                repository.Delete(obj4delete);
                context.SaveChanges();
                msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, obj4delete.AccessToken);
                return new BaseActionResult(true, msg);
            }
        }