コード例 #1
0
        public JsonResult GetPageLists(int page, int pageSize, string keywords = "")
        {
            ResultDto <List <Dto.DemdInfoDto> > result = new ResultDto <List <Dto.DemdInfoDto> >();

            try
            {
                ResultDto <List <DemdInfo> > items = new ResultDto <List <DemdInfo> >();
                DemdInfoService ObjServ            = new DemdInfoService();
                if (!string.IsNullOrEmpty(keywords))
                {
                    items = ObjServ.Reposity.GetPageList(page, pageSize, o => (o.Title.Contains(keywords) && o.TenantId == TenantId));
                }
                else
                {
                    items = ObjServ.Reposity.GetPageList(page, pageSize, o => o.TenantId == TenantId);
                }
                result = Mapper.Map <ResultDto <List <Dto.DemdInfoDto> > >(items);
                ObjServ.Dispose();
            }
            catch (Exception ex)
            {
                result.code    = 500;
                result.message = ex.Message;
            }
            return(Json(result));
        }
コード例 #2
0
        public JsonResult InsertOrUpdate(DemdInfo input)
        {
            ResultDto <long> result = new ResultDto <long>();

            try
            {
                using (DemdInfoService ObjServ = new DemdInfoService())
                {
                    if (input.Id == 0)
                    {
                        input.CreationTime = DateTime.Now;
                    }
                    input.TenantId = TenantId;
                    ObjServ.Reposity.InsertOrUpdate(input);
                    result.code    = 100;
                    result.datas   = input.Id;
                    result.message = "ok";
                }
            }
            catch (Exception ex)
            {
                result.code    = 500;
                result.message = ex.Message;
            }
            return(Json(result));
        }
コード例 #3
0
        public JsonResult GetLists(int page, int pageSize, string keywords = "")
        {
            DemdInfoService ObjServ = new DemdInfoService();
            var             items   = ObjServ.Reposity.GetPageList(page, pageSize, o => o.IsChecked && o.TenantId == tenant.Id);
            var             result  = Mapper.Map <ResultDto <List <Dto.DemdInfoDto> > >(items);

            if (result.datas != null)
            {
                result.datas = result.datas.OrderByDescending(o => o.CreationTime).ToList();
            }
            ObjServ.Dispose();
            return(Json(result));
        }
コード例 #4
0
        public JsonResult GetModel(long id)
        {
            DemdInfo        model   = new DemdInfo();
            DemdInfoService ObjServ = new DemdInfoService();
            var             result  = ObjServ.Reposity.FirstOrDefault(id);

            if (result != null)
            {
                model = result;
            }
            var entity = Mapper.Map <Dto.DemdInfoDto>(model);

            ObjServ.Dispose();
            return(Json(entity));
        }
コード例 #5
0
        public JsonResult Del(long id)
        {
            ResultDto <string> result = new ResultDto <string>();

            try
            {
                DemdInfoService ObjServ = new DemdInfoService();
                ObjServ.Reposity.Delete(id);
                result.code    = 100;
                result.message = "success";
            }
            catch (Exception ex)
            {
                result.message = ex.Message;
            }
            return(Json(result));
        }
コード例 #6
0
        public JsonResult Checked(long id)
        {
            ResultDto <long> result = new ResultDto <long>();

            try
            {
                using (DemdInfoService ObjServ = new DemdInfoService())
                {
                    var input = ObjServ.Reposity.FirstOrDefault(id);
                    input.IsChecked = input.IsChecked ? false : true;
                    ObjServ.Reposity.InsertOrUpdate(input);
                    result.code    = 100;
                    result.datas   = input.Id;
                    result.message = "ok";
                }
            }
            catch (Exception ex)
            {
                result.code    = 500;
                result.message = ex.Message;
            }
            return(Json(result));
        }
コード例 #7
0
        public JsonResult InsertOrUpdate(Core.DemdInfo input)
        {
            ResultDto <long> result = new ResultDto <long>();

            try
            {
                DemdInfoService ObjServ = new DemdInfoService();
                input.TenantId      = tenant.Id;
                input.CreatorUserId = MemberId;
                input.CreationTime  = DateTime.Now;
                ObjServ.Reposity.InsertOrUpdate(input);
                ObjServ.Dispose();
                result.code    = 100;
                result.message = "ok";
                result.datas   = input.Id;
            }
            catch (Exception ex)
            {
                result.code    = 500;
                result.message = ex.Message;
            }
            return(Json(result));
        }