Exemplo n.º 1
0
 public static bool DeleteClient(int number)
 {
     using (var db = new TravelAgencyContext())
     {
         int    count  = db.Clients.Count();
         Client client = null;
         client = db.Clients.Where(x => x.ClientNumber == number).First();
         db.Clients.Remove(client);
         try
         {
             db.SaveChanges();
         }
         catch (DbUpdateException ex)
         {
             throw ex;
         }
         if (db.Clients.Count() + 1 == count)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 2
0
 public static void UpdateWorker(Worker worker)
 {
     using (var db = new TravelAgencyContext())
     {
         db.Entry(worker).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public static bool InsertWorkerOrder(Order order, Worker worker)
 {
     using (var db = new TravelAgencyContext())
     {
         int count = db.Workers.Where(x => x.WorkerNumber == worker.WorkerNumber).First().WorkerOrders.Count;
         db.Workers.Where(x => x.WorkerNumber == worker.WorkerNumber).First().WorkerOrders.Add(order);
         db.SaveChanges();
         if (count + 1 == db.Workers.Where(x => x.WorkerNumber == worker.WorkerNumber).First().WorkerOrders.Count)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 4
0
 public static bool InsertClient(Client client)
 {
     using (var db = new TravelAgencyContext())
     {
         int count = db.Clients.Count();
         db.Clients.Add(client);
         db.SaveChanges();
         if (count + 1 == db.Clients.Count())
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 5
0
 public static bool InsertOffer(Offer offer)
 {
     using (var db = new TravelAgencyContext())
     {
         int count = db.Offers.Count();
         db.Offers.Add(offer);
         db.SaveChanges();
         if (count + 1 == db.Offers.Count())
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 6
0
 public static bool InsertOrder(Order order)
 {
     using (var db = new TravelAgencyContext())
     {
         int count = db.Orders.Count();
         db.Entry(order.ServiceWorker).State = EntityState.Unchanged;
         db.Orders.Add(order);
         db.SaveChanges();
         if (count + 1 == db.Orders.Count())
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }