public ActionResult Index(NewsEntry entry) { if (ModelState.IsValid) { if (entry.NewsId == 0) { entry.CreatedBy = Utility.CurrentUserName; entry.CreatedTime = DateTime.UtcNow; Utility.Operate(this, Operations.Add, () => _news.Add(entry), entry.Title); } else { var info = _news.GetById(entry.NewsId); info.ChangedBy = Utility.CurrentUserName; info.ChangedTime = DateTime.UtcNow; info.Content = entry.Content; info.ModuleId = entry.ModuleId; Utility.Operate(this, Operations.Update, () => _news.Update(info), info.Title); } } else { Utility.SetErrorModelState(this); } return(Redirect("~/Admin/About/Index?MenuID=" + entry.ParentId)); }
public object AddNews([FromBody] string email) { if (this.IsValidEmail(email)) { return(_News.Add(email)); } else { return(0); } }
public ActionResult Create(NewsEntry model) { if (ModelState.IsValid) { model.CreatedBy = Utility.CurrentUserName; model.CreatedTime = DateTime.UtcNow; Utility.Operate(this, Operations.Add, () => _news.Add(model), model.Title); } else { Utility.SetErrorModelState(this); } return(Redirect("~/Admin/News/Index?MenuID=" + model.ParentId)); }
public ActionResult ActionCreate(SBH_TM_NEWS NEWSView, HttpPostedFileBase postedFile) { string a = Request.Form["storeImage"]; try { string encodedString = Server.HtmlEncode(NEWSView.DESCRIPTION); NEWSView.DESCRIPTION = encodedString; string physicalPath = ""; if (postedFile != null) { string ImageName = System.IO.Path.GetFileName(postedFile.FileName); //file2 to store path and url physicalPath = Server.MapPath("~" + Common.GetPathFolderImg() + ImageName); NEWSView.FILE_IMAGE1 = Common.GetPathFolderImg() + ImageName; } NEWSView.CREATED_BY = Session["UserId"].ToString(); NEWSView.CREATED_TIME = DateTime.Now; rs = repo.Add(NEWSView); if (rs.IsSuccess) { if (physicalPath != "") { postedFile.SaveAs(physicalPath); } rs.SetSuccessStatus("Data has been created successfully"); TempData["msgSuccess"] = rs.MessageText; } else { rs.SetErrorStatus("Data failed to created"); TempData["msgError"] = rs.MessageText; } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); rs.SetErrorStatus("Data failed to created"); TempData["msgError"] = rs.MessageText; } return(RedirectToAction("Index")); }
public bool Add(E_Model.News model) { return(dal.Add(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.News model) { return(dal.Add(model)); }