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())); } } }
/// <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()); }
public IHttpActionResult GetDeliveryProduct() { using (ctx = new YwtDbContext()) { return(Ok(ctx.DeliveryProduct.ToList())); } }
public IHttpActionResult GetDeliveryPowerList() { using (ctx = new YwtDbContext()) { var list = ctx.DeliveryPower.ToList(); return(Ok(list)); } }
public IHttpActionResult GetDeliveryPower(int mgid) { using (ctx = new YwtDbContext()) { var list = ctx.DeliveryPower.Where(m => m.Mgroupid == mgid); return(Ok(list.ToList())); } }
public IHttpActionResult GetManageGroupList() { using (ctx = new YwtDbContext()) { var list = ctx.ManageGroup.Where(m => m.status == 1); return(Ok(list.ToList())); } }
public IHttpActionResult GetDesignPlan(int applyid) { using (ctx = new YwtDbContext()) { var list = ctx.DesignPlan.Where(p => applyid == p.ApplyId); return(Ok(list.ToList())); } }
public IHttpActionResult GetDeliveryReceipt(int applyid) { using (ctx = new YwtDbContext()) { var entity = ctx.DeliveryReceipt.FirstOrDefault(m => m.ApplyId == applyid); return(Ok(entity)); } }
public IHttpActionResult GetApplyDesignManager() { using (YwtDbContext db = new YwtDbContext()) { var entity = db.ApplyDesignManager.FirstOrDefault(); return(Ok(entity)); } }
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)); } }
public IHttpActionResult GetDesignEvent() { using (ctx = new YwtDbContext()) { var entitys = ctx.DesignEvent.AsQueryable().ToList(); return(Ok(entitys)); } }
public IHttpActionResult CreateDeliveryPower([FromBody] DeliveryPower input) { using (ctx = new YwtDbContext()) { ctx.DeliveryPower.Add(input); ctx.SaveChanges(); return(Ok()); } }
public PersonInfo GetPersonInfo(string name) { using (YwtDbContext ctx = new YwtDbContext()) { var entity = ctx.PersonInfo.FirstOrDefault(m => m.name == name); return(entity); } }
public ApplyDesignManager GetApplyDesignManager() { using (YwtDbContext ctx = new YwtDbContext()) { var entity = ctx.ApplyDesignManager.FirstOrDefault(); return(entity); } }
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()); } }
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("删除成功")); } }
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)); } }
// 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)); } }
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()); } }
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)); } }
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)); } }
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))); } }
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("")); } }
/// <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(); } }
// 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)); } }
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)); } }
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)); } }
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()); } }
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)); } }
// 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)); } }