public ActionResult CreateArticle(Article art) { try { try { String filename = System.IO.Path.GetFileNameWithoutExtension(art.Imagefile.FileName); String extension = System.IO.Path.GetExtension(art.Imagefile.FileName); filename = filename + DateTime.Now.ToString("yymmssfff") + extension; art.photo = "~/Images/" + filename; filename = System.IO.Path.Combine(Server.MapPath("~/Images"), filename); art.Imagefile.SaveAs(filename); s1.CreateArticle(art); } catch (Exception e) { ViewBag.err = "ERREUR"; return(View("CreateArticle")); } return(RedirectToAction("GestionArticle")); } catch (Exception) { return(View("Error")); } }
/// <summary> /// 发布新文章 /// </summary> /// <param name="article">文章信息</param> /// <param name="user">用户信息</param> void IArticle.Publish(TArticleLang article, TUser user) { using (TransactionScope scope = new TransactionScope()) { string id = m_iArticle.CreateArticle(); article.ArticleId = id; article.UserId = user.UserId; m_iArticle.Create(article); scope.Complete(); } }