Example #1
0
        public ActionResult Create(Header header)
        {
            if (ModelState.IsValid)
            {
                db.Header.AddObject(header);
                db.SaveChanges();
                return RedirectToAction("Logon", "Account");
            }

            return View(header);
        }
Example #2
0
        public ActionResult Edit(Header header, HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                header.IsImage = true;

                var fileName = System.IO.Path.GetFileName(file.FileName);
                // store the file inside ~/App_Data/uploads folder
                var path = System.IO.Path.Combine(Server.MapPath("~/Content/images"), fileName);
                file.SaveAs(path);

                header.ImagePath = fileName;
            }
            if (ModelState.IsValid)
            {
                db.Header.Attach(header);
                db.ObjectStateManager.ChangeObjectState(header, EntityState.Modified);
                db.SaveChanges();
                return RedirectToAction("Logon", "Account");
            }
            return View(header);
        }
Example #3
0
 /// <summary>
 /// Create a new Header object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="isImage">Initial value of the IsImage property.</param>
 /// <param name="culture">Initial value of the Culture property.</param>
 /// <param name="class">Initial value of the Class property.</param>
 public static Header CreateHeader(global::System.Int32 id, global::System.Boolean isImage, global::System.Int32 culture, global::System.Int32 @class)
 {
     Header header = new Header();
     header.Id = id;
     header.IsImage = isImage;
     header.Culture = culture;
     header.Class = @class;
     return header;
 }
Example #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Header EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToHeader(Header header)
 {
     base.AddObject("Header", header);
 }