public ActionResult Edit(Contragent contragent)
 {
     if (ModelState.IsValid && Contragent.Update(contragent))
     {
         return RedirectToAction("Index");
     }
     return View(contragent);
 }
示例#2
0
        public static bool Create(Contragent contragent)
        {
            bool result = true;
            try
            {
                db.Contragents.AddObject(contragent);
                db.SaveChanges();
            }
            catch (Exception)
            {
                result = false;
            }

            return result;
        }
示例#3
0
        public static bool Update(Contragent contragent)
        {
            bool result = true;
            try
            {
                EntityDataModelContainer mc = new EntityDataModelContainer();
                mc.Contragents.Attach(contragent);
                mc.ObjectStateManager.ChangeObjectState(contragent, EntityState.Modified);
                mc.SaveChanges();
                db.Refresh(System.Data.Objects.RefreshMode.StoreWins, contragent);
            }
            catch (Exception)
            {
                result = false;
            }

            return result;
        }
 /// <summary>
 /// Create a new Contragent object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="fIO">Initial value of the FIO property.</param>
 /// <param name="phone">Initial value of the Phone property.</param>
 /// <param name="address">Initial value of the Address property.</param>
 /// <param name="eMail">Initial value of the EMail property.</param>
 public static Contragent CreateContragent(global::System.Int32 id, global::System.String fIO, global::System.String phone, global::System.String address, global::System.String eMail)
 {
     Contragent contragent = new Contragent();
     contragent.Id = id;
     contragent.FIO = fIO;
     contragent.Phone = phone;
     contragent.Address = address;
     contragent.EMail = eMail;
     return contragent;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Contragents EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContragents(Contragent contragent)
 {
     base.AddObject("Contragents", contragent);
 }