Exemplo n.º 1
0
        public ActionResult Create(FormCollection form)
        {

            using (var context = new SiteContainer())
            {
                var article = new Article { Name = "" };
                TryUpdateModel(article, new[] { "Name", "Title", "Date", "Description" });
                article.Text = HttpUtility.HtmlDecode(form["Text"]);
                context.AddToArticle(article);
                context.SaveChanges();
            }
            return RedirectToAction("Articles", "Home", new { area = "" });

        }
Exemplo n.º 2
0
        public ActionResult Create(FormCollection form, HttpPostedFileBase fileUpload)
        {

            using (var context = new SiteContainer())
            {
                var article = new Article { Name = "" };
                TryUpdateModel(article, new[] { "Name", "Title", "Date", "Description","PageTitle"});
                article.Text = HttpUtility.HtmlDecode(form["Text"]);
                article.OldPrice = HttpUtility.HtmlDecode(form["OldPrice"]);
                article.NewPrice = HttpUtility.HtmlDecode(form["NewPrice"]);
                if (fileUpload != null)
                {
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/Images");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);
                    article.ImageSource = fileName;
                }
                context.AddToArticle(article);
                context.SaveChanges();
            }
            return RedirectToAction("Articles", "Home", new { area = "" });

        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new Article object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 public static Article CreateArticle(global::System.Int32 id, global::System.DateTime date, global::System.String name, global::System.String title, global::System.String description)
 {
     Article article = new Article();
     article.Id = id;
     article.Date = date;
     article.Name = name;
     article.Title = title;
     article.Description = description;
     return article;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Article EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToArticle(Article article)
 {
     base.AddObject("Article", article);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create a new Article object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="text">Initial value of the Text property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="oldPrice">Initial value of the OldPrice property.</param>
 /// <param name="newPrice">Initial value of the NewPrice property.</param>
 /// <param name="imageSource">Initial value of the ImageSource property.</param>
 public static Article CreateArticle(global::System.Int32 id, global::System.DateTime date, global::System.String name, global::System.String title, global::System.String text, global::System.String description, global::System.String oldPrice, global::System.String newPrice, global::System.String imageSource)
 {
     Article article = new Article();
     article.Id = id;
     article.Date = date;
     article.Name = name;
     article.Title = title;
     article.Text = text;
     article.Description = description;
     article.OldPrice = oldPrice;
     article.NewPrice = newPrice;
     article.ImageSource = imageSource;
     return article;
 }