public ActionResult Add(FormCollection collection) { { string idlogin = User.Identity.Name; var Idmaster = StoreDb.Webmasters.Single(m=>m.Username == idlogin); Website w = new Website(); w.DateJoin = DateTime.Now; w.WebmasterId = Idmaster.Id; foreach (var key in collection.AllKeys) { if (key == "Title") w.Title = collection[key]; else if(key=="URL") w.URL = collection[key]; else if(key == "Description") w.Description = collection[key]; } w.Status = 0;//chua duoc validate StoreDb.Websites.AddObject(w); StoreDb.SaveChanges(); TransactionLogViewModel.AddLog("Webmaster: " + idlogin + " has just added the website: "+w.URL+" successfully!", DateTime.Now); return RedirectToAction("AddDone"); } }
public ActionResult Add(FormCollection collection) { //try { string idlogin = User.Identity.Name; var Idmaster = StoreDb.Webmasters.Single(m=>m.Username == idlogin); Website w = new Website(); w.DateJoin = DateTime.Now; w.WebmasterId = Idmaster.Id; foreach (var key in collection.AllKeys) { if (key == "Title") w.Title = collection[key]; if(key=="URL") w.URL = collection[key]; if(key == "Description") w.Description = collection[key]; } StoreDb.Websites.AddObject(w); StoreDb.SaveChanges(); return RedirectToAction("Add"); } }
/// <summary> /// Deprecated Method for adding a new object to the Websites EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToWebsites(Website website) { base.AddObject("Websites", website); }
/// <summary> /// Create a new Website object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="webmasterId">Initial value of the WebmasterId property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="uRL">Initial value of the URL property.</param> public static Website CreateWebsite(global::System.Int32 id, global::System.Int32 webmasterId, global::System.String title, global::System.String uRL) { Website website = new Website(); website.Id = id; website.WebmasterId = webmasterId; website.Title = title; website.URL = uRL; return website; }