public ActionResult SendToApp(SubscribeAndWarning subscribeAndWarning) { List <SelectListItem> staff = (from s in db.Staffs join d in db.Departments on s.Department equals d.DepartmentId select new { StaffNumber = s.StaffNumber, StaffName = s.Name, StaffDepartment = d.Name, StaffPosition = s.Position, HomeTelNumber = s.HomeTelNumber }).ToList().Select(s => new SelectListItem { Text = s.StaffNumber + "-" + s.StaffName + "-" + s.StaffDepartment + "-" + s.StaffPosition + "-" + s.HomeTelNumber, Value = s.HomeTelNumber }).ToList(); ViewBag.Receiver = staff; if (ModelState.IsValid) { subscribeAndWarning.Receiver = Request["Receiver"]; db.SubscribeAndWarnings.Add(subscribeAndWarning); db.SaveChanges(); //if (subscribeAndWarning.SendToApp == true) { // JpushController Jpush = new JpushController(); // Jpush.JpushTest(); //} return(RedirectToAction("Index")); } return(View(subscribeAndWarning)); }
public ActionResult DeleteConfirmed(int id) { SubscribeAndWarning subscribeAndWarning = db.SubscribeAndWarnings.Find(id); db.SubscribeAndWarnings.Remove(subscribeAndWarning); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: SubscribeAndWarning/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubscribeAndWarning subscribeAndWarning = db.SubscribeAndWarnings.Find(id); if (subscribeAndWarning == null) { return(HttpNotFound()); } return(View(subscribeAndWarning)); }
// GET: SubscribeAndWarning/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubscribeAndWarning subscribeAndWarning = db.SubscribeAndWarnings.Find(id); if (subscribeAndWarning == null) { return(HttpNotFound()); } //ViewBag.StartCut = subscribeAndWarning.StartDate.ToString("yyyy-MM-dd"); return(View(subscribeAndWarning)); }
public ActionResult Edit(SubscribeAndWarning subscribeAndWarning) { List <SelectListItem> circulateMethod = new List <SelectListItem>(); SelectListItem a1 = new SelectListItem { Text = "仅一次", Value = "0" }; SelectListItem a2 = new SelectListItem { Text = "每天", Value = "1" }; circulateMethod.Add(a1); circulateMethod.Add(a2); ViewBag.CirculateMethod = circulateMethod; //SubScribeList怎么来?SystemDb里面 SystemDbContext systemdb = new SystemDbContext(); List <SelectListItem> subScribeList = (from p in systemdb.SubscribeLists where p.IsAvailable == true select new { SubscribeName = p.SubscribeName, SubscribeId = p.Id }).ToList().Select(s => new SelectListItem { Text = s.SubscribeName, Value = s.SubscribeId.ToString() }).ToList(); ViewBag.SubScribeList = subScribeList; if (subscribeAndWarning.CirculateMethod == 0) { subscribeAndWarning.StartDate = null; subscribeAndWarning.EndDate = null; } if (subscribeAndWarning.CirculateMethod == 1) { subscribeAndWarning.OnlyOneDate = null; } List <SelectListItem> staff = (from s in db.Staffs join d in db.Departments on s.Department equals d.DepartmentId select new { StaffNumber = s.StaffNumber, StaffName = s.Name, StaffDepartment = d.Name, StaffPosition = s.Position }).ToList().Select(s => new SelectListItem { Text = s.StaffNumber + "-" + s.StaffName + "-" + s.StaffDepartment + "-" + s.StaffPosition, Value = s.StaffNumber + "-" + s.StaffName + "-" + s.StaffDepartment + "-" + s.StaffPosition }).ToList(); ViewBag.Receiver = staff; if (ModelState.IsValid) { SubscribeAndWarning temp = db.SubscribeAndWarnings.Find(subscribeAndWarning.Id); temp.CirculateMethod = subscribeAndWarning.CirculateMethod; temp.EndDate = subscribeAndWarning.EndDate; temp.EventName = subscribeAndWarning.EventName; temp.SubscribeContent = subscribeAndWarning.SubscribeContent; temp.IsAvailable = subscribeAndWarning.IsAvailable; temp.IsEmail = subscribeAndWarning.IsEmail; temp.MessageBody = subscribeAndWarning.MessageBody; temp.MessageAlert = subscribeAndWarning.MessageAlert; temp.MessageTitle = subscribeAndWarning.MessageTitle; temp.Receiver = Request["Receiver"]; temp.ReceiverName = subscribeAndWarning.ReceiverName; temp.ReceiverTel = subscribeAndWarning.ReceiverTel; temp.ReceiverType = subscribeAndWarning.ReceiverType; temp.RemindDate = subscribeAndWarning.RemindDate; temp.ReceiverEmail = subscribeAndWarning.ReceiverEmail; temp.SendToApp = subscribeAndWarning.SendToApp; temp.StartDate = subscribeAndWarning.StartDate; temp.CirculateMethod = subscribeAndWarning.CirculateMethod; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subscribeAndWarning)); }
// GET: SubscribeAndWarning/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubscribeAndWarning subscribeAndWarning = db.SubscribeAndWarnings.Find(id); if (subscribeAndWarning == null) { return(HttpNotFound()); } List <SelectListItem> staff = (from s in db.Staffs join d in db.Departments on s.Department equals d.DepartmentId select new { StaffNumber = s.StaffNumber, StaffName = s.Name, StaffDepartment = d.Name, StaffPosition = s.Position }).ToList().Select(s => new SelectListItem { Text = s.StaffNumber + "-" + s.StaffName + "-" + s.StaffDepartment + "-" + s.StaffPosition, Value = s.StaffNumber + "-" + s.StaffName + "-" + s.StaffDepartment + "-" + s.StaffPosition }).ToList(); ViewBag.Receiver = staff; List <SelectListItem> circulateMethod = new List <SelectListItem>(); SelectListItem a1 = new SelectListItem { Text = "仅一次", Value = "0" }; SelectListItem a2 = new SelectListItem { Text = "每天", Value = "1" }; circulateMethod.Add(a1); circulateMethod.Add(a2); ViewBag.CirculateMethod = circulateMethod; //SubScribeList怎么来?SystemDb里面 SystemDbContext systemdb = new SystemDbContext(); List <SelectListItem> subScribeList = (from p in systemdb.SubscribeLists where p.IsAvailable == true select new { SubscribeName = p.SubscribeName, SubscribeId = p.Id }).ToList().Select(s => new SelectListItem { Text = s.SubscribeName, Value = s.SubscribeId.ToString() }).ToList(); ViewBag.SubScribeList = subScribeList; return(View(subscribeAndWarning)); }
public ActionResult Create(SubscribeAndWarning subscribeAndWarning) { List <SelectListItem> staff = (from s in db.Staffs join d in db.Departments on s.Department equals d.DepartmentId select new { StaffNumber = s.StaffNumber, StaffName = s.Name, StaffEmail = s.Email, StaffPhone = s.IndividualTelNumber //手机号码 // StaffDepartment = d.Name, // StaffPosition = s.Position }).ToList().Select(s => new SelectListItem { Text = s.StaffNumber + "-" + s.StaffName, Value = s.StaffNumber + "-" + s.StaffName + "<" + s.StaffPhone + "-" + s.StaffEmail + ">" // backlog.Recipient; //Text = s.StaffNumber + "-" + s.StaffName + "-" + s.StaffDepartment + "-" + s.StaffPosition, //Value = s.StaffNumber + "-" + s.StaffName + "-" + s.StaffDepartment + "-" + s.StaffPosition }).ToList(); ViewBag.Receiver = staff; List <SelectListItem> circulateMethod = new List <SelectListItem>(); SelectListItem a1 = new SelectListItem { Text = "仅一次", Value = "0" }; SelectListItem a2 = new SelectListItem { Text = "每天", Value = "1" }; //SelectListItem a3 = new SelectListItem //{ // Text = "每周", // Value = "2" //}; //SelectListItem a4 = new SelectListItem //{ // Text = "每月", // Value = "3" //}; //SelectListItem a5 = new SelectListItem //{ // Text = "每年", // Value = "4" //}; //SelectListItem a6 = new SelectListItem //{ // Text = "自定义", // Value = "5" //}; circulateMethod.Add(a1); circulateMethod.Add(a2); //circulateMethod.Add(a3); //circulateMethod.Add(a4); //circulateMethod.Add(a5); //circulateMethod.Add(a6); ViewBag.CirculateMethod = circulateMethod; //SubScribeList怎么来?SystemDb里面 SystemDbContext systemdb = new SystemDbContext(); List <SelectListItem> subScribeList = (from p in systemdb.SubscribeLists where p.IsAvailable == true select new { SubscribeName = p.SubscribeName, SubscribeId = p.Id }).ToList().Select(s => new SelectListItem { Text = s.SubscribeName, Value = s.SubscribeId.ToString() }).ToList(); ViewBag.SubScribeList = subScribeList; if (subscribeAndWarning.CirculateMethod == 0) { subscribeAndWarning.StartDate = null; subscribeAndWarning.EndDate = null; } if (subscribeAndWarning.CirculateMethod == 1) { subscribeAndWarning.OnlyOneDate = null; } if (ModelState.IsValid) { //backlog中的电子邮箱和手机号码 // backlog.TelNum = backlog.Recipient; string[] sArray = subscribeAndWarning.Receiver.Split(new char[] { ',' }); foreach (var itemsArray in sArray) { string[] temp = itemsArray.Split(new char[3] { '-', '<', '>' }); subscribeAndWarning.ReceiverTel += temp[2]; subscribeAndWarning.ReceiverTel += ","; subscribeAndWarning.ReceiverEmail += temp[3]; subscribeAndWarning.ReceiverEmail += ","; } //subscribeAndWarning.Receiver = Request["Receiver"]; db.SubscribeAndWarnings.Add(subscribeAndWarning); db.SaveChanges(); //if (subscribeAndWarning.SendToApp == true) { // JpushController Jpush = new JpushController(); // Jpush.JpushTest(); //} return(RedirectToAction("Index")); } return(View(subscribeAndWarning)); }