/// <summary> /// 删除指定ID数据 /// </summary> /// <param name="Id">实时交易信息ID</param> /// <returns></returns> public Result_Msg DeleteById(long Id, long userId) { Result_Msg res = new Result_Msg(); WhatBusy job = (from p in context.WhatBusy where p.Id == Id select p).FirstOrDefault(); context.WhatBusy.Remove(job); res.IsSuccess = context.SaveChanges() == 1; return(res); }
public string GetObjectById(int Id) { WhatBusy res = new WhatBusy(); if (base.CurrentManager != null && base.CurrentManager.Id > 0) { long userId = base.CurrentManager.Id; res = whatBuys.GetObjectById(Id); } else { } return(Newtonsoft.Json.JsonConvert.SerializeObject(res)); }
/// <summary> /// 获取实时交易信息详情 /// </summary> /// <param name="Id"></param> /// <param name="userId"></param> /// <returns></returns> public WhatBusy GetObjectById(int Id) { WhatBusy model = (from p in context.WhatBusy where p.Id == Id select p).FirstOrDefault(); WhatBusy res = new WhatBusy() { Id = model.Id, BusyCotent = model.BusyCotent, BusyType = model.BusyType, IsShow = model.IsShow, UserId = model.UserId, TargetUrl = model.TargetUrl, CreateDate = model.CreateDate }; return(res); }
public Result_Model <WhatBusy> UpdateWhatBusy_By_WhatBusyType(QueryCommon <WhatBusyQuery> query) { Result_Model <WhatBusy> res = new Result_Model <WhatBusy>() { Msg = new Result_Msg(), Model = new WhatBusy() }; WhatBusy whatBusy = new WhatBusy(); #region 除之前记录 var whatBusyList = from p in context.WhatBusy where p.BusyType == query.ParamInfo.BusyType select p; if (whatBusyList.Any()) { foreach (var item in whatBusyList) { context.WhatBusy.Remove(item); } int count = context.SaveChanges(); } #endregion #region 新增新记录 //数据来源类型(1:用户注册;2:定制合成;3:代理采购;4:招聘信息;5:会议信息;6:技术交易;) switch (query.ParamInfo.BusyType) { case 1: #region 用户注册 var list1 = (from p in context.UserMemberInfo orderby p.CreateDate descending select p).Take(query.ParamInfo.TopCount).ToList(); foreach (var item in list1) { int userType = (from p in context.UserMemberInfo where p.Id == item.Id select p.UserType).FirstOrDefault(); whatBusy = new WhatBusy() { BusyType = query.ParamInfo.BusyType, IsShow = 1, TargetUrl = string.Empty, UserId = item.Id, UserName = job.GetCompanyInfo_ByUserIdAndUserType(item.Id), BusyCotent = hashSet.Get_DictionariesList_ByTypeID(15).Where(x => x.DKey == userType.ToString()).FirstOrDefault().DValue, CreateDate = item.CreateDate }; context.WhatBusy.Add(whatBusy); } #endregion break; case 2: #region 定制合成 var list2 = (from p in context.OrderSynthesis orderby p.OrderTime descending select p).Take(query.ParamInfo.TopCount).ToList(); foreach (var item in list2) { whatBusy = new WhatBusy() { BusyType = query.ParamInfo.BusyType, IsShow = 1, TargetUrl = string.Empty, UserId = item.UserId, UserName = item.CompanyName, BusyCotent = item.ProductName, CreateDate = item.OrderTime }; context.WhatBusy.Add(whatBusy); } #endregion break; case 3: #region 代理采购 var list3 = (from p in context.OrderPurchasing orderby p.OrderTime descending select p).Take(query.ParamInfo.TopCount).ToList(); foreach (var item in list3) { whatBusy = new WhatBusy() { BusyType = query.ParamInfo.BusyType, IsShow = 1, TargetUrl = string.Empty, UserId = item.UserId, UserName = item.CompanyName, BusyCotent = item.ProductName, CreateDate = item.OrderTime }; context.WhatBusy.Add(whatBusy); } #endregion break; case 4: #region 招聘信息 var list4 = (from p in context.Jobs orderby p.CreateDate descending select p).Take(query.ParamInfo.TopCount).ToList(); foreach (var item in list4) { whatBusy = new WhatBusy() { BusyType = query.ParamInfo.BusyType, IsShow = 1, TargetUrl = string.Empty, UserId = item.UserId, UserName = job.GetCompanyInfo_ByUserIdAndUserType(item.UserId), BusyCotent = item.JobTitle, CreateDate = item.CreateDate }; context.WhatBusy.Add(whatBusy); } #endregion break; case 5: #region 会议信息 var list5 = (from p in context.MeetingInfo orderby p.CreatDate descending select p).Take(query.ParamInfo.TopCount).ToList(); foreach (var item in list5) { whatBusy = new WhatBusy() { BusyType = query.ParamInfo.BusyType, IsShow = 1, TargetUrl = string.Empty, UserId = item.UserId, UserName = job.GetCompanyInfo_ByUserIdAndUserType(item.UserId), BusyCotent = item.Title, CreateDate = item.CreatDate }; context.WhatBusy.Add(whatBusy); } #endregion break; case 6: #region 技术交易 var list6 = (from p in context.TechnicalInfo orderby p.PublishTime descending select p).Take(query.ParamInfo.TopCount).ToList(); foreach (var item in list6) { whatBusy = new WhatBusy() { BusyType = query.ParamInfo.BusyType, IsShow = 1, TargetUrl = string.Empty, UserId = item.PublisherId, UserName = job.GetCompanyInfo_ByUserIdAndUserType(item.PublisherId), BusyCotent = item.Title, CreateDate = item.PublishTime }; context.WhatBusy.Add(whatBusy); } #endregion break; default: break; } #endregion res.Msg.IsSuccess = context.SaveChanges() > 0; return(res); }