Example #1
0
 public void RemoveCompany(company company)
 {
     using (db_consolesEntities db = new db_consolesEntities())
     {
         if (db.companies.FirstOrDefault(x => x.ID == company.ID) != null)
         {
             db.Entry(company).State = System.Data.EntityState.Deleted;
             db.SaveChanges();
             ListUpdated?.Invoke();
         }
     }
 }
Example #2
0
 public void UpdateCompany(company company)
 {
     try
     {
         using (db_consolesEntities db = new db_consolesEntities())
         {
             Validate(company);
             db.Entry(company).State = System.Data.EntityState.Modified;
             db.SaveChanges();
             ListUpdated?.Invoke();
         }
     }
     catch (ArgumentException)
     { throw; }
     catch (Exception)
     {
         throw new Exception("Something wrong happened while updating the company's info.");
     }
 }