public ActionResult Update(int?id, int curPage) { if (Request.Form != null && Request.Form.Count > 0) { resp = importantEventService.UpdateImportantEvent(Request); return(this.JudgeResult(resp, () => RedirectToAction("Details", new { curpage = curPage, msg = string.Format("更新了事项:{0}", Request.Form["content"]) }))); } else { ImportantEvent importantEvent = null; resp = importantEventService.GetImportantEvent((int)id, () => importantEvent = new ImportantEvent()); return(this.JudgeResult(resp, () => { conta_ImportantEvent = new Container_ImportantEvent() { importantEvent = importantEvent, CurPage = curPage }; return View(conta_ImportantEvent); })); } }
private void SetValue(HttpRequestBase req, ImportantEvent importantEvent, bool isAdd) { if (!isAdd) { importantEvent.Id = Convert.ToInt32(req.Form["id"]); } importantEvent.Content = req.Form["content"].ToString(); importantEvent.PublisTime = Convert.ToDateTime(req.Form["publish"]); }
public ActionResult Index(string todoValue, string importantEventName, DateTime?importantEventDate) { var userId = User.Identity.GetUserId(); if (todoValue != null) { if (_context.Todoes.Where(x => x.UserProfileId == userId).Count() < 16) { var todo = new Todo { TodoId = _context.Todoes.Count() + 1, TodoValue = todoValue, UserProfileId = userId }; _context.Todoes.Add(todo); } } if (importantEventName != null && importantEventDate != null) { if (_context.ImportantEvents.Where(x => x.UserProfileId == userId).Count() < 16) { var importantEvent = new ImportantEvent { ImportantEventId = _context.ImportantEvents.Count() + 1, ImportantEventName = importantEventName, ImportantEventDate = importantEventDate, UserProfileId = userId }; _context.ImportantEvents.Add(importantEvent); } } _context.SaveChanges(); ModelState.Clear(); TodoViewModel model = new TodoViewModel { Todoes = _context.Todoes.Where(x => x.UserProfileId == userId).ToList(), ImportantEvents = _context.ImportantEvents.Where(x => x.UserProfileId == userId).ToList() }; if (todoValue != null) { return(PartialView("_TodoTable", model)); } if (importantEventName != null && importantEventDate != null) { return(PartialView("_ImportantEventTable", model)); } else { return(View()); } }
public override bool Insert(object obj) { if (!(obj is ImportantEvent)) { return(false); } ImportantEvent importantEvent = (ImportantEvent)obj; dalBase.sql = "INSERT INTO db_importantEvent(content,publishTime) VALUES (@content,@publishTime)"; dalBase.List_param = new List <MySqlParameter>() { new MySqlParameter("@content", importantEvent.Content), new MySqlParameter("@publishTime", importantEvent.PublisTime) }; return(dalBase.Run(Behavious.INSERT_OR_UPDATE_OR_DELETE, true)); }
public override bool Update(object obj) { if (!(obj is ImportantEvent)) { return(false); } ImportantEvent importantEvent = (ImportantEvent)obj; dalBase.sql = "UPDATE db_importantEvent SET content=@content,publishTime=@publishTime WHERE id=@id"; dalBase.List_param = new List <MySqlParameter>() { new MySqlParameter("@content", importantEvent.Content), new MySqlParameter("@publishTime", importantEvent.PublisTime), new MySqlParameter("@id", importantEvent.Id) }; return(dalBase.Run(Behavious.INSERT_OR_UPDATE_OR_DELETE, true)); }
public override ResponseStatus GetSingle(int id, object obj) { if (obj is ImportantEvent) { ImportantEvent importantEvent = (ImportantEvent)obj; dalBase.sql = "SELECT * FROM db_importantEvent WHERE id=@id"; dalBase.Param = new MySqlParameter("@id", id); bool isSuccess = dalBase.Run(Behavious.SELECT_WITH_SINGLEPARAM, false); return(this.JudgeDBResult(isSuccess, () => { dalBase.DataRead.Read(); importantEvent.Id = Convert.ToInt32(dalBase.DataRead["id"]); importantEvent.Content = dalBase.DataRead["content"].ToString(); importantEvent.PublisTime = Convert.ToDateTime(dalBase.DataRead["publishTime"]); }, null)); } else { return(ResponseStatus.FAILED); } }