Ejemplo n.º 1
0
        public IHttpActionResult Get(
            int?limit       = null,
            int?page        = null,
            string status   = null,
            string date1    = null,
            string date2    = null,
            string memberid = null,
            string orderBy  = null,
            bool ascending  = true)
        {
            using (ctx = new YwtDbContext())
            {
                var chain = ctx.DeliveryApply.AsQueryable();

                if (status != null)
                {
                    chain = chain.Where(n => n.Status == status);
                }
                if (memberid != null)
                {
                    chain = chain.Where(n => n.Memberid == memberid);
                }
                if (date1 != null && date2 != null)
                {
                    DateTime d1 = Convert.ToDateTime(date1);
                    DateTime d2 = Convert.ToDateTime(date2);
                    chain = chain.Where(m => m.CreateTime > d1 && m.CreateTime < d2);
                }

                switch (orderBy == null ? null : orderBy.ToLower())
                {
                case "id":
                    chain = ascending ? chain.OrderBy(p => p.Id) : chain.OrderByDescending(p => p.Id);
                    break;

                default:
                    chain = chain.OrderByDescending(p => p.Id);
                    break;
                }

                if (limit != null)
                {
                    var envelope = new Envelope {
                        Limit = limit, Page = page, Total = chain.Count()
                    };
                    if (page != null)
                    {
                        chain = chain.Skip((page.Value - 1) * limit.Value);
                    }
                    chain = chain.Take(limit.Value);
                    var entites = chain.ToList();
                    return(Ok(entites.ToList(), envelope));
                }
                else
                {
                    var entites = chain.ToList();
                    return(Ok(entites.ToList()));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 立即申请表单页
        /// </summary>
        /// <param name="source"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public ActionResult ApplyInfo(string source, string userid)
        {
            if (string.IsNullOrEmpty(source))
            {
                source = "微信";
            }

            ViewBag.source  = source;
            ViewBag.userid  = userid;
            ViewBag.curtime = DateTime.Now.Ticks;


            if (!string.IsNullOrEmpty(userid))
            {
                using (YwtDbContext ctx = new YwtDbContext())
                {
                    var entity = ctx.DesignApply.FirstOrDefault(m => m.apply_userId == userid);
                    if (entity != null && entity.apply_id > 0)
                    {
                        return(RedirectToAction("Successful", new { applyid = entity.apply_id }));
                    }
                }
            }


            return(View());
        }
Ejemplo n.º 3
0
 public IHttpActionResult GetDeliveryProduct()
 {
     using (ctx = new YwtDbContext())
     {
         return(Ok(ctx.DeliveryProduct.ToList()));
     }
 }
Ejemplo n.º 4
0
 public IHttpActionResult GetDeliveryPowerList()
 {
     using (ctx = new YwtDbContext())
     {
         var list = ctx.DeliveryPower.ToList();
         return(Ok(list));
     }
 }
Ejemplo n.º 5
0
 public IHttpActionResult GetDeliveryPower(int mgid)
 {
     using (ctx = new YwtDbContext())
     {
         var list = ctx.DeliveryPower.Where(m => m.Mgroupid == mgid);
         return(Ok(list.ToList()));
     }
 }
Ejemplo n.º 6
0
 public IHttpActionResult GetManageGroupList()
 {
     using (ctx = new YwtDbContext())
     {
         var list = ctx.ManageGroup.Where(m => m.status == 1);
         return(Ok(list.ToList()));
     }
 }
Ejemplo n.º 7
0
 public IHttpActionResult GetDesignPlan(int applyid)
 {
     using (ctx = new YwtDbContext())
     {
         var list = ctx.DesignPlan.Where(p => applyid == p.ApplyId);
         return(Ok(list.ToList()));
     }
 }
Ejemplo n.º 8
0
 public IHttpActionResult GetDeliveryReceipt(int applyid)
 {
     using (ctx = new YwtDbContext())
     {
         var entity = ctx.DeliveryReceipt.FirstOrDefault(m => m.ApplyId == applyid);
         return(Ok(entity));
     }
 }
Ejemplo n.º 9
0
 public IHttpActionResult GetApplyDesignManager()
 {
     using (YwtDbContext db = new YwtDbContext())
     {
         var entity = db.ApplyDesignManager.FirstOrDefault();
         return(Ok(entity));
     }
 }
Ejemplo n.º 10
0
 public IHttpActionResult GetInfoByKeyWord(string keyword)
 {
     using (ctx = new YwtDbContext())
     {
         var list = GetList().Where(m => m.Name.Contains(keyword) || keyword == m.Id.ToString());
         return(Ok(list));
     }
 }
Ejemplo n.º 11
0
 public IHttpActionResult GetDesignEvent()
 {
     using (ctx = new YwtDbContext())
     {
         var entitys = ctx.DesignEvent.AsQueryable().ToList();
         return(Ok(entitys));
     }
 }
Ejemplo n.º 12
0
 public IHttpActionResult CreateDeliveryPower([FromBody] DeliveryPower input)
 {
     using (ctx = new YwtDbContext())
     {
         ctx.DeliveryPower.Add(input);
         ctx.SaveChanges();
         return(Ok());
     }
 }
Ejemplo n.º 13
0
        public PersonInfo GetPersonInfo(string name)
        {
            using (YwtDbContext ctx = new YwtDbContext())
            {
                var entity = ctx.PersonInfo.FirstOrDefault(m => m.name == name);

                return(entity);
            }
        }
Ejemplo n.º 14
0
        public ApplyDesignManager GetApplyDesignManager()
        {
            using (YwtDbContext ctx = new YwtDbContext())
            {
                var entity = ctx.ApplyDesignManager.FirstOrDefault();

                return(entity);
            }
        }
Ejemplo n.º 15
0
 public IHttpActionResult DeleteDeliveryMenu(int id)
 {
     using (ctx = new YwtDbContext())
     {
         var entity = ctx.DeliveryMenu.FirstOrDefault(m => m.Id == id);
         ctx.DeliveryMenu.Remove(entity);
         ctx.SaveChanges();
         return(Ok());
     }
 }
Ejemplo n.º 16
0
 public IHttpActionResult DeleteDeliveryApplyProduct(int id)
 {
     using (ctx = new YwtDbContext())
     {
         var list = ctx.DeliveryApplyProduct.FirstOrDefault(m => m.Id == id);
         ctx.DeliveryApplyProduct.Remove(list);
         ctx.SaveChanges();
         return(Ok("删除成功"));
     }
 }
Ejemplo n.º 17
0
 public IHttpActionResult Post([FromBody] DesignApply entity)
 {
     using (ctx = new YwtDbContext())
     {
         entity.apply_createTime = DateTime.Now;
         entity.apply_status     = ApplyStaus.WaitAuditing.ToString();
         ctx.DesignApply.Add(entity);
         ctx.SaveChanges();
         return(Ok(entity));
     }
 }
Ejemplo n.º 18
0
 // GET api/values/5
 public IHttpActionResult Get(int id)
 {
     using (ctx = new YwtDbContext())
     {
         var entity = ctx.DesignApply.FirstOrDefault(p => id == p.apply_id);
         if (null == entity)
         {
             return(NotFound());
         }
         return(Ok(entity));
     }
 }
Ejemplo n.º 19
0
 public IHttpActionResult CreateDeliveryProduct([FromBody] DeliveryProduct input)
 {
     using (ctx = new YwtDbContext())
     {
         input.LastUpdateTime = DateTime.Now;
         input.CreateTime     = DateTime.Now;
         input.Status         = 1;
         ctx.DeliveryProduct.Add(input);
         ctx.SaveChanges();
         return(Ok());
     }
 }
Ejemplo n.º 20
0
        public IHttpActionResult Get(string uid)
        {
            using (ctx = new YwtDbContext())
            {
                var entity = GetList().FirstOrDefault(m => m.Uid == uid);
                if (entity == null)
                {
                    return(Ok(""));
                }

                return(Ok(entity));
            }
        }
Ejemplo n.º 21
0
 public IHttpActionResult GetStatistics()
 {
     using (ctx = new YwtDbContext())
     {
         var model = new ActivitySuperScholarStatistic()
         {
             JoinCount  = ctx.ActivitySuperScholar.Count(),
             LikesCount = ctx.ActivitySuperScholar.Sum(m => m.Likes),
             PvCount    = ctx.ActivitySuperScholar.Sum(m => m.AccessNum)
         };
         return(Ok(model));
     }
 }
Ejemplo n.º 22
0
        public IHttpActionResult Get(int id)
        {
            using (ctx = new YwtDbContext())
            {
                var entity = ctx.DeliveryApply.Include("DeliveryApplyProducts").FirstOrDefault(m => m.Id == id);
                if (entity == null)
                {
                    return(NotFound());
                }

                return(Ok(Mapper.Map <DeliveryApplyDto>(entity)));
            }
        }
Ejemplo n.º 23
0
 public IHttpActionResult Post([FromBody] DeliveryApply input)
 {
     using (ctx = new YwtDbContext())
     {
         input.Num            = DateTime.Now.ToString("yyyyMMddHHmmss");
         input.Status         = DeliveryApplyStatus.WaitAudit.ToString();
         input.CreateTime     = DateTime.Now;
         input.LastUpdateTime = DateTime.Now;
         ctx.DeliveryApply.Add(input);
         ctx.SaveChanges();
         return(Ok(""));
     }
 }
Ejemplo n.º 24
0
        /// <summary>
        /// 增加pv
        /// </summary>
        /// <param name="id"></param>
        public void AddPv(int id)
        {
            using (ctx = new YwtDbContext())
            {
                var entity = ctx.ActivitySuperScholar.FirstOrDefault(m => m.Id == id);
                if (entity == null)
                {
                    return;
                }

                entity.AccessNum += 1;
                ctx.SaveChanges();
            }
        }
Ejemplo n.º 25
0
 // POST api/superscholar
 public IHttpActionResult Post([FromBody] ActivitySuperScholarCreateDto input)
 {
     using (ctx = new YwtDbContext())
     {
         var entity = new ActivitySuperScholar();
         Mapper.Map <ActivitySuperScholarCreateDto, ActivitySuperScholar>(input, entity);
         entity.CreateTime = DateTime.Now;
         entity.Likes      = 0;
         entity.AccessNum  = 0;
         ctx.ActivitySuperScholar.Add(entity);
         ctx.SaveChanges();
         return(Ok(entity));
     }
 }
Ejemplo n.º 26
0
        public IHttpActionResult PostDeliveryInvoice([FromBody] DeliveryInvoice input)
        {
            using (ctx = new YwtDbContext())
            {
                input.CreateTime = DateTime.Now;
                ctx.DeliveryInvoice.Add(input);
                var entity = ctx.DeliveryApply.FirstOrDefault(m => m.Id == input.ApplyId);
                entity.Status         = DeliveryApplyStatus.WaitReceived.ToString();
                entity.LastUpdateTime = DateTime.Now;

                ctx.SaveChanges();
                return(Ok(input));
            }
        }
Ejemplo n.º 27
0
        public IHttpActionResult PostDesignPlan([FromBody] DesignPlan entity)
        {
            using (ctx = new YwtDbContext())
            {
                var enty = ctx.DesignApply.FirstOrDefault(m => m.apply_id == entity.ApplyId);
                enty.plan_status = false;   //上传方案后   方案状态变为未提交

                entity.CreateTime     = DateTime.Now;
                entity.DesignFilePath = entity.DesignFilePath.Trim('"');
                ctx.DesignPlan.Add(entity);
                ctx.SaveChanges();
                return(Ok(entity));
            }
        }
Ejemplo n.º 28
0
 public IHttpActionResult DeleteDeliveryPower(int id)
 {
     using (ctx = new YwtDbContext())
     {
         var entity = ctx.DeliveryPower.FirstOrDefault(m => m.Id == id);
         if (entity == null)
         {
             return(NotFound());
         }
         ctx.DeliveryPower.Remove(entity);
         ctx.SaveChanges();
         return(Ok());
     }
 }
Ejemplo n.º 29
0
 public IHttpActionResult Put([FromBody] MoreDesignApplyDto input)
 {
     using (ctx = new YwtDbContext())
     {
         var entity = ctx.DesignApply.FirstOrDefault(m => m.apply_id == input.apply_id);
         if (null == entity)
         {
             return(NotFound());
         }
         Mapper.Map <MoreDesignApplyDto, DesignApply>(input, entity);
         ctx.SaveChanges();
         return(Ok(entity));
     }
 }
Ejemplo n.º 30
0
        // GET v1/superscholar/5
        public IHttpActionResult Get(int id)
        {
            using (ctx = new YwtDbContext())
            {
                var entity = GetList().FirstOrDefault(m => m.Id == id);
                if (entity == null)
                {
                    return(NotFound());
                }

                AddPv(id);

                return(Ok(entity));
            }
        }