Esempio n. 1
0
 public ActionResult Create(FormCollection collection)
 {
     // TODO: Add insert logic here
     var v = new Contractor();
     UpdateModel(v);
     repo.Add(v);
     return RedirectToAction("Index");
 }
        public bool Replace(int id, int replaceID)
        {
            Contractor e = Get(id);
            Contractor replaceContractor = Get(replaceID);

            if (e == null || replaceContractor == null)
            {
                return(false);
            }
            else
            {
                IQueryable <Site> sL = DB.Sites.Where(r => r.ContractorID == replaceID);
                foreach (var item in sL)
                {
                    item.ContractorID = id;
                }

                IQueryable <Contract> cL = DB.Contracts.Where(r => r.ContractorID == replaceID);
                foreach (var item in cL)
                {
                    item.ContractorID = id;
                }

                Save();

                var contactL = replaceContractor.ContractorContacts.ToList();
                foreach (var item in contactL)
                {
                    var contactDetailL = item.ContractorContactDetails.ToList();
                    foreach (var itemDetail in contactDetailL)
                    {
                        DB.ContractorContactDetails.DeleteObject(itemDetail);
                    }
                    DB.ContractorContacts.DeleteObject(item);
                }

                DB.Contractors.DeleteObject(replaceContractor);
                Save();

                return(true);
            }
        }
 public void Delete(Contractor e)
 {
     DB.Contractors.DeleteObject(e);
     Save();
 }
 public Contractor Update(Contractor e)
 {
     Save();
     return(e);
 }
 public Contractor Add(Contractor e)
 {
     DB.Contractors.AddObject(e);
     Save();
     return(e);
 }
Esempio n. 6
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Contractors EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContractors(Contractor contractor)
 {
     base.AddObject("Contractors", contractor);
 }
Esempio n. 7
0
 /// <summary>
 /// Create a new Contractor object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static Contractor CreateContractor(global::System.Int32 id)
 {
     Contractor contractor = new Contractor();
     contractor.ID = id;
     return contractor;
 }
Esempio n. 8
0
 public Contractor Update(Contractor e)
 {
     Save();
     return e;
 }
Esempio n. 9
0
 public void Delete(Contractor e)
 {
     DB.Contractors.DeleteObject(e);
     Save();
 }
Esempio n. 10
0
 public Contractor Add(Contractor e)
 {
     DB.Contractors.AddObject(e);
     Save();
     return e;
 }