예제 #1
0
 public ActionResult Edit(FormCollection sitemodel)
 {
     int userID = int.Parse((from c in db.contacts where c.username == User.Identity.Name select c.id).FirstOrDefault().ToString());
     if (ModelState.IsValid)
     {
         site s ;
             long? id = long.Parse(sitemodel["id"]);
             if (id == -1)
             {
                 s = new site();
                 s.denumire = sitemodel["denumire"].ToString();
                 s.judetID = int.Parse(sitemodel["judet"]);
                 s.createDate = DateTime.Now;
                 s.editDate = null;
                 s.editContactID = null;
                 s.createContactID = userID;
                 s.disabled = 0;
                 db.AddTosites(s);
                 db.SaveChanges();
             }
             else
             {
                 s = db.sites.Where(o => o.id == id).FirstOrDefault();
                 s.denumire = sitemodel["denumire"].ToString();
                 s.editContactID = userID;
                 s.editDate = DateTime.Now;
                 db.SaveChanges();
             }
         var namejudet = (from j in db.judetes where j.id == s.judetID select j.denumire).FirstOrDefault();
         return RedirectToAction("Index", "Judete", new { name = namejudet, id = s.id.ToString() + "_site" });
     }
     else
     {
         return Json("Salvarea nu a fost efectuata!");
     }
 }
예제 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the sites EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTosites(site site)
 {
     base.AddObject("sites", site);
 }
예제 #3
0
 /// <summary>
 /// Create a new site object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="judetID">Initial value of the judetID property.</param>
 /// <param name="denumire">Initial value of the denumire property.</param>
 /// <param name="siteParinteID">Initial value of the siteParinteID property.</param>
 public static site Createsite(global::System.Int64 id, global::System.Int32 judetID, global::System.String denumire, global::System.Int64 siteParinteID)
 {
     site site = new site();
     site.id = id;
     site.judetID = judetID;
     site.denumire = denumire;
     site.siteParinteID = siteParinteID;
     return site;
 }