/// <summary> /// 创建一条案例信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool CreateRegister(RegisterInfo model) { using (var db = new SRISDBEntities()) { db.RegisterInfo.Add(model); FollowDetails fdModel = new FollowDetails() { CaseId = model.RegisterInfoID, CreateDataTime = DateTime.Now, Id = System.Guid.NewGuid().ToString(), ImageUrl = "", MesText = "添加案例" }; db.FollowDetails.Add(fdModel); if (db.SaveChanges() > 0) { return(true); } else { return(false); } } }
/// <summary> /// 通过案例类型ID获取案例类型 /// </summary> /// <param name="id">例类型ID</param> /// <returns></returns> public SRType GetSRTypeById(string id) { using (var db = new SRISDBEntities()) { return(db.SRType.Where(n => n.SRTypeID == id).FirstOrDefault()); } }
/// <summary> /// 通过案例ID获取案例信息 /// </summary> /// <param name="Id"></param> /// <returns></returns> public RegisterInfo GetRegisterInfoById(string Id) { using (var db = new SRISDBEntities()) { return(db.RegisterInfo.Find(Id)); } }
/// <summary> /// 设置为宝贝回家案例 /// </summary> /// <param name="id">要设置的案例ID</param> /// <returns></returns> public bool Bbhj(string id) { using (var db = new SRISDBEntities()) { var tran = db.Database.BeginTransaction(); try { // 修改案例状态为宝贝回家案例 RegisterInfo model = db.RegisterInfo.Find(id); model.IsBBHJ = 1; // 宝贝回家表添加数据 BBHJInfo bbModel = new BBHJInfo() { BBHJCode = "", BBHJInfoID = System.Guid.NewGuid().ToString(), CreateDateTime = DateTime.Now, GuideTime = DateTime.Now, RegisterInfoID = id, Remark = "", Volunteer = "" }; db.BBHJInfo.Add(bbModel); db.SaveChanges(); tran.Commit(); return(true); } catch (Exception e) { tran.Rollback(); return(false); } } }
/// <summary> /// 通过用户名查询用户信息 /// </summary> /// <param name="userName">用户名</param> /// <returns></returns> public UserInfo GetUserInfoByUserName(string userName) { using (var db = new SRISDBEntities()) { var userInfo = db.UserInfo.Where(n => n.UserName == userName).SingleOrDefault(); return(userInfo); } }
/// <summary> /// 通过案例ID获取联系人信息 /// </summary> /// <param name="CaseId">案例ID</param> /// <returns></returns> public LinkMan GetLinManModelById(string CaseId) { using (var db = new SRISDBEntities()) { LinkMan model = db.LinkMan.Where(n => n.RegisterInfoId == CaseId).FirstOrDefault(); return(model); } }
/// <summary> /// 获取所有的案例类型 /// </summary> /// <returns></returns> public List <SRType> GetSRType() { using (var db = new SRISDBEntities()) { List <SRType> SRTypeList = db.SRType.ToList(); return(SRTypeList); } }
/// <summary> /// 新用户注册 /// </summary> /// <param name="model">用户注册信息实体类</param> /// <returns></returns> public bool Register(UserInfo model) { using (var db = new SRISDBEntities()) { db.UserInfo.Add(model); db.SaveChanges(); return(true); } }
/// <summary> /// 删除案例登记信息 /// </summary> /// <param name="id">案例登记ID</param> /// <returns></returns> public bool DelRegisterInfo(string id) { using (var db = new SRISDBEntities()) { RegisterInfo model = db.RegisterInfo.Find(id); model.IsDelete = 1; db.SaveChanges(); return(true); } }
/// <summary> /// 创建宝贝回家案例 /// </summary> /// <param name="model">宝贝回家案例实体类</param> /// <returns></returns> public bool CreateBBHJCase(BBHJInfo model) { using (var db = new SRISDBEntities()) { db.BBHJInfo.Add(model); RegisterInfo info = db.RegisterInfo.Find(model.RegisterInfoID); info.IsBBHJ = 1; db.SaveChanges(); return(true); } }
/// <summary> /// 修改案例跟进信息 /// </summary> /// <param name="model">案例跟进信息实体类</param> /// <returns></returns> public bool UpdateFollowDetails(FollowDetails model) { using (var db = new SRISDBEntities()) { FollowDetails dfModel = db.FollowDetails.Find(model.Id); dfModel.ImageUrl = model.ImageUrl; dfModel.MesText = model.MesText; db.SaveChanges(); return(true); } }
/// <summary> /// 获取所有的宝贝回家案例 /// </summary> /// <returns></returns> public List <BBHJCaseModel> GetAllBBHJCase(string userid, int page, int limit, Dictionary <string, string> whereDic, out int pageCount) { using (var db = new SRISDBEntities()) { List <BBHJCaseModel> list = (from n in db.RegisterInfo join b in db.BBHJInfo on n.RegisterInfoID equals b.RegisterInfoID join t in db.SRType on n.SRTypeID equals t.SRTypeID where (n.UserInfoID == userid && n.IsBBHJ == 1 && n.IsDelete == 0 && n.IsReturnTask == 0 && n.IsSuccess == 0) orderby b.CreateDateTime descending select new BBHJCaseModel() { BBHJCode = b.BBHJCode, BeSeekerName = n.BeSeekerName, CaseCode = n.CaseCode, GetTaskDate = n.GetTaskDateTime, GuideTime = b.GuideTime, RegisterLink = n.RegisterLink, Remarks = b.Remark, SRTypeID = t.SRTypeID, SRTypeName = t.SRTypeName, Title = n.Title, Volunteer = b.Volunteer, RegisterInfoId = n.RegisterInfoID, BBHJInfoID = b.BBHJInfoID }).ToList(); if (whereDic != null) { if (!string.IsNullOrEmpty(whereDic["caseCode"])) { list = list.Where(n => n.CaseCode.Contains(whereDic["caseCode"])).ToList(); } if (!string.IsNullOrEmpty(whereDic["srTypeId"])) { list = list.Where(n => n.SRTypeID == whereDic["srTypeId"]).ToList(); } if (!string.IsNullOrEmpty(whereDic["beSeekerName"])) { list = list.Where(n => n.BeSeekerName.Contains(whereDic["beSeekerName"])).ToList(); } if (!string.IsNullOrEmpty(whereDic["getTaskDate"])) { list = list.Where(n => n.GetTaskDate == Convert.ToDateTime(whereDic["getTaskDate"])).ToList(); } } pageCount = list.Count; if (page > 0 && limit > 0) { list = list.Skip((page - 1) * limit).Take(limit).ToList(); } return(list); } }
/// <summary> /// 创建联系人信息 /// </summary> /// <param name="model">联系人信息实体类</param> /// <returns></returns> public bool CreateLinkMan(LinkMan model) { using (var db = new SRISDBEntities()) { db.LinkMan.Add(model); if (db.SaveChanges() > 0) { return(true); } else { return(false); } } }
/// <summary> /// 删除跟进信息 /// </summary> /// <param name="id">跟进信息ID</param> /// <returns></returns> public bool DelFollowDetail(string id) { using (var db = new SRISDBEntities()) { FollowDetails model = db.FollowDetails.Find(id); model.IsDel = 1; if (db.SaveChanges() > 0) { return(true); } else { return(false); } } }
/// <summary> /// 获取所有的登记案例的信息 /// </summary> /// <returns></returns> public List <RegisterModel> GetAllCaseInfo(string userId) { using (var db = new SRISDBEntities()) { List <RegisterModel> list = (from n in db.RegisterInfo join p in db.SRType on n.SRTypeID equals p.SRTypeID where n.UserInfoID == userId && n.IsReturnTask == 0 && n.IsBBHJ == 0 && n.IsDelete == 0 && n.IsSuccess == 0 orderby n.GetTaskDateTime descending select new RegisterModel() { RegisterInfo = n, SRTypeName = p.SRTypeName }).ToList(); return(list); } }
/// <summary> /// 获取所有的登记案例的信息 /// </summary> /// <returns></returns> public List <RegisterModel> GetAllCaseInfo(string userId, int page, int limit, Dictionary <string, string> whereDic, out int pageCount) { using (var db = new SRISDBEntities()) { //List<RegisterInfo> list = db.RegisterInfo // .Where(n => n.UserInfo.UserInfoID == userId && n.IsReturnTask == 0 && n.IsBBHJ == "0" && n.IsDelete == 0 && n.IsSuccess == 0) // //.Include(t => t.SRType) // .OrderByDescending(s => s.GetTaskDateTime) // .ToList(); List <RegisterModel> list = (from n in db.RegisterInfo join p in db.SRType on n.SRTypeID equals p.SRTypeID where n.UserInfoID == userId && n.IsReturnTask == 0 && n.IsBBHJ == 0 && n.IsDelete == 0 && n.IsSuccess == 0 orderby n.GetTaskDateTime descending select new RegisterModel() { RegisterInfo = n, SRTypeName = p.SRTypeName }).ToList(); if (whereDic != null) { if (!string.IsNullOrEmpty(whereDic["caseCode"])) { list = list.Where(n => n.RegisterInfo.CaseCode.Contains(whereDic["caseCode"])).ToList(); } if (!string.IsNullOrEmpty(whereDic["srTypeId"])) { list = list.Where(n => n.RegisterInfo.SRTypeID == whereDic["srTypeId"]).ToList(); } if (!string.IsNullOrEmpty(whereDic["beSeekerName"])) { list = list.Where(n => n.RegisterInfo.BeSeekerName.Contains(whereDic["beSeekerName"])).ToList(); } if (!string.IsNullOrEmpty(whereDic["getTaskDate"])) { list = list.Where(n => n.RegisterInfo.GetTaskDateTime == Convert.ToDateTime(whereDic["getTaskDate"])).ToList(); } } pageCount = list.Count; if (page > 0 && limit > 0) { list = list.Skip((page - 1) * limit).Take(limit).ToList(); } return(list); } }
/// <summary> /// 设置为成功案例 /// </summary> /// <param name="id">案例ID</param> /// <returns></returns> public bool SetSuccess(string id) { using (var db = new SRISDBEntities()) { RegisterInfo model = db.RegisterInfo.Find(id); if (model != null) { model.IsSuccess = 1; db.SaveChanges(); return(true); } else { return(false); } } }
/// <summary> /// 通过跟进信息ID获取跟进信息 /// </summary> /// <param name="id">跟进信息ID</param> /// <returns></returns> public SRIS.Model.FollowDetailsModel GetModel(string id) { using (var db = new SRISDBEntities()) { var list = (from n in db.FollowDetails where n.Id == id && n.IsDel == 0 select new SRIS.Model.FollowDetailsModel() { CaseId = n.CaseId, CreateDataTime = n.CreateDataTime, Id = n.Id, ImageUrl = n.ImageUrl, MesText = n.MesText }).ToList(); return(list[0]); } }
/// <summary> /// 修改案例信息 /// </summary> /// <param name="model">案例信息实体类</param> /// <returns></returns> public bool UpdateRegisterInfo(RegisterInfo model) { using (var db = new SRISDBEntities()) { RegisterInfo md = db.RegisterInfo.Find(model.RegisterInfoID); md.BeSeekerName = model.BeSeekerName; md.CaseCode = model.CaseCode; md.GetTaskDateTime = model.GetTaskDateTime; md.PostLink = model.PostLink; md.RegisterLink = model.RegisterLink; md.Remarks = model.Remarks; md.SRTypeID = model.SRTypeID; md.Title = model.Title; md.IsReturnTask = model.IsReturnTask; md.ReturnReason = model.ReturnReason; db.SaveChanges(); return(true); } }
/// <summary> /// 新建跟进信息 /// </summary> /// <param name="imageUrl">上传图片</param> /// <param name="gjxx">跟进信息</param> /// <param name="id">案例ID</param> /// <returns></returns> public bool CreateFollowDetail(string imageUrl, string gjxx, string id) { using (var db = new SRISDBEntities()) { FollowDetails model = new FollowDetails() { CaseId = id, CreateDataTime = DateTime.Now, Id = Guid.NewGuid().ToString(), ImageUrl = imageUrl, MesText = gjxx }; db.FollowDetails.Add(model); if (db.SaveChanges() > 0) { return(true); } else { return(false); } } }
/// <summary> /// 修改联系人信息 /// </summary> /// <param name="model">联系人信息实体类</param> /// <returns></returns> public bool UpdateLinkMan(LinkMan model) { using (var db = new SRISDBEntities()) { LinkMan linkManModel = db.LinkMan.Find(model.LinkManID); linkManModel.Address = model.Address; linkManModel.Birthday = model.Birthday; linkManModel.Career = model.Career; linkManModel.CreateDateTime = model.CreateDateTime; linkManModel.Email = model.Email; linkManModel.IdCardNo = model.IdCardNo; linkManModel.LinkManName = model.LinkManName; linkManModel.OtherLink = model.OtherLink; linkManModel.Phone = model.Phone; linkManModel.QQ = model.QQ; linkManModel.Relationship = model.Relationship; linkManModel.Remark = model.Remark; linkManModel.Sex = model.Sex; linkManModel.TelPhone = model.TelPhone; linkManModel.WeiXin = model.WeiXin; db.SaveChanges(); return(true); } }