예제 #1
0
        public ActionResult List(int offset, int limit, string search)
        {
            IQueryable <InfoBanner> articles;

            if (string.IsNullOrEmpty(search))
            {
                articles = repository.GetAllList(offset, limit);
            }
            else
            {
                articles = repository.GetAllList(offset, limit, m => m.title.Contains(search));
            }
            var total = repository.Count();

            return(Jsonp(new { total = total, rows = articles }, JsonRequestBehavior.AllowGet));
        }  // GET: Users/Details/5
예제 #2
0
        public ActionResult List(int offset, int limit, string search)
        {
            IQueryable <TotalMessage> articles;

            if (string.IsNullOrEmpty(search))
            {
                articles = repository.GetAllList(offset, limit);
            }
            else
            {
                articles = repository.GetAllList(offset, limit, m => m.remark.Contains(search));
            }
            var total = repository.Count();

            return(Jsonp(new { total = total, rows = articles }, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public async Task <JsonpResult> List(int offset, int limit, string search, long categoryid)
        {
            IQueryable <Article> articles;
            var total = 0;

            if (string.IsNullOrEmpty(search))
            {
                if (categoryid != 0L)
                {
                    var allC = await GetAllCategoriesByIdAsync(categoryid);

                    articles = repository.GetAllList(offset, limit, m => m.categoryId, allC.ToArray());
                    total    = repository.Count(m => m.categoryId, allC.ToArray());
                }
                else
                {
                    articles = repository.GetAllList(offset, limit);
                    total    = repository.Count();
                }
            }
            else
            {
                if (categoryid != 0L)
                {
                    var allC = await GetAllCategoriesByIdAsync(categoryid);

                    articles = repository.GetAllList(offset, limit, m => m.title.Contains(search) || m.creatorName.Contains(search), m => m.categoryId, allC.ToArray());
                    total    = repository.Count(m => m.title.Contains(search) || m.creatorName.Contains(search), m => m.categoryId, allC.ToArray());
                }
                else
                {
                    articles = repository.GetAllList(offset, limit, m => m.title.Contains(search) || m.creatorName.Contains(search));
                    total    = repository.Count(m => m.title.Contains(search) || m.creatorName.Contains(search));
                }
            }
            //var result = Mapper.Map<IQueryable<User>, IList<UserDto>>(users);

            return(Jsonp(new { total = total, rows = articles }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult List(int offset, int limit, string search, long?id)
        {
            if (id == null)
            {
                return(Jsonp(new { total = 0, rows = 0 }, JsonRequestBehavior.AllowGet));
            }
            IQueryable <ArticleComment> articles;

            if (string.IsNullOrEmpty(search))
            {
                articles = repository.GetAllList(offset, limit, m => m.articleId == id);
            }
            else
            {
                articles = repository.GetAllList(offset, limit, m => (m.contents.Contains(search) || m.creatorName.Contains(search)) && m.articleId == id);
            }
            var total = repository.Count();

            return(Jsonp(new { total = total, rows = articles }, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public JsonpResult List(int offset, int limit, string search)
        {
            IList <ArticleCategory> oldList;

            if (string.IsNullOrEmpty(search))
            {
                oldList = easonRepository.GetAllList(offset, limit).ToList();
            }
            else
            {
                oldList = easonRepository.GetAllList(offset, limit, m => m.title.Contains(search)).ToList();
            }
            //原始根
            var roots = oldList.Where(i => i.parentId == 0);
            //获取所有父亲
            var parents = oldList.GroupBy(m => m.parentId).Select(x => x.FirstOrDefault()).Where(i => i.parentId != 0).OrderBy(m => m.id).ToList();
            var newList = new List <ArticleCategory>();

            foreach (var item in roots)
            {
                parents.Add(item);
                // newList.Add(item);
            }
            parents = parents.OrderBy(m => m.parentId).ToList();
            for (int i = 0; i < parents.Count(); i++)
            {
                if (!newList.Contains(parents[i]))
                {
                    newList.Add(parents[i]);
                    GetChild(parents[i].id, oldList, newList);
                }
            }



            var total = easonRepository.Count();

            return(Jsonp(new { total = total, rows = newList }, JsonRequestBehavior.AllowGet));
        }
        public async System.Threading.Tasks.Task <ActionResult> Index(string phone)
        {
            var result = new ResultModel();

            if (string.IsNullOrEmpty(phone))
            {
                result.Code    = 1001;
                result.Message = " 手机号格式不正确 ";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }

            if (!Utility.RegexUtils.IsPhone(phone))
            {
                result.Code    = 1002;
                result.Message = " 手机号格式不正确 ";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
            var res = new EasonRepository <User, long>();

            if (res.Count(m => m.telephone == phone) > 0)
            {
                result.Code    = 1003;
                result.Message = " 该手机号已经注册过了 ";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
            var date = DateTime.Now.AddMinutes(-1);
            var re   = repository.FirstOrDefault(m => m.telephone == phone && m.creationTime > date);

            if (re != null)
            {
                result.Code    = 1004;
                result.Message = " 请一分钟后再次发送 ";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
            date = DateTime.Now.AddMinutes(60);
            if (repository.Count(m => m.ip == UserHostAddress && m.creationTime > date) > 1000)
            {
                result.Code    = 1005;
                result.Message = " 该IP一小时内发送的短信数量过多";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
            IMessageService service = new MessageService();

            try
            {
                var msg = new ShortMessage();
                msg.creatorId    = 1;
                msg.creatorName  = "注册用户";
                msg.creationTime = DateTime.Now;
                msg.telephone    = phone;
                msg.code         = new Random().Next(1000, 9999);
                msg.content      = "验证码" + msg.code + ",您正在注册成为匹优爱用户,感谢您的支持!";
                msg.ip           = UserHostAddress;
                await repository.InsertAsync(msg);

                await repository.UnitOfWork.CommitAsync();

                service.Register(msg.code.ToString(), msg.telephone);
                result.Code    = 0;
                result.Message = string.Empty;
                result.Data    = "发送成功!";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                result.Code    = 1001;
                result.Message = ex.Message;
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
        }