public List <Car> GetCars(int OwnerId) { using (var context = new WorkschopContext()) { return(context.Cars.Where(c => c.OwnerId == OwnerId).ToList()); } }
public List <Owner> GetOwners() { using (var context = new WorkschopContext()) { return(context.Owners.ToList()); } }
public void ChangePhoneNumber(int id, string newPhoneNumber) { using (var context = new WorkschopContext()) { var changedOwner = context.Owners.Find(id); if (changedOwner != null) { changedOwner.PhoneNumber = newPhoneNumber; context.SaveChanges(); } } }
public void BeginOrder(int carId, string orderName) { using (var context = new WorkschopContext()) { var order = new Order() { CarId = carId, Name = orderName, StartDate = DateTime.Now, EndDate = null }; context.Orders.Add(order); context.SaveChanges(); } }
public void Delete(int carId) { using (var context = new WorkschopContext()) { try { context.Remove(context.Cars.Find(carId)); context.SaveChanges(); } catch (Exception exception) { Console.WriteLine(exception.Message); } } }
public void Add(string name, string surname, string phoneNumber) { var newOwner = new Owner() { Name = name, Surname = surname, PhoneNumber = phoneNumber }; using (var context = new WorkschopContext()) { context.Owners.Add(newOwner); context.SaveChanges(); } }
public void Add(int activityId, string name, decimal price) { var part = new Part() { ActivityId = activityId, Name = name, Price = price }; using (var context = new WorkschopContext()) { context.Parts.Add(part); context.SaveChanges(); } }
public void ChangeActivity(int activityId, decimal laborPrice) { using (var context = new WorkschopContext()) { var changedActivity = context.Activities.Find(activityId); try { changedActivity.LaborPrice = laborPrice; context.SaveChanges(); } catch (Exception exception) { Console.WriteLine(exception.Message); } } }
public void Delete(int activityId) { using (var context = new WorkschopContext()) { try { var activity = context.Activities.Find(activityId); context.Activities.Remove(activity); context.SaveChanges(); } catch (NullReferenceException exception) { Console.WriteLine(exception.Message); } } }
public void EndOrder(int orderId) { using (var context = new WorkschopContext()) { try { var order = context.Orders.Find(orderId); order.EndDate = DateTime.Now; context.SaveChanges(); } catch (Exception exception) { Console.WriteLine(exception.Message); } } }
public void Add(int ownerId, string mark, string model, string registration) { var newCar = new Car() { OwnerId = ownerId, Mark = mark, Model = model, Registration = registration }; using (var context = new WorkschopContext()) { context.Cars.Add(newCar); context.SaveChanges(); } }
public void Delete(int id) { using (var context = new WorkschopContext()) { var deletedOwner = context.Owners.Find(id); try { context.Remove(deletedOwner); context.SaveChanges(); } catch (Exception exception) { Console.WriteLine(exception.Message); } } }
public void Delete(int partId) { using (var context = new WorkschopContext()) { try { var part = context.Parts.Find(partId); context.Parts.Remove(part); context.SaveChanges(); } catch (Exception exception) { Console.WriteLine(exception.Message); } } }
public void ChangeActivity(int activityId, string newName) { using (var context = new WorkschopContext()) { var changedActivity = context.Activities.Find(activityId); try { if (changedActivity != null) { changedActivity.Name = newName; context.SaveChanges(); } } catch (Exception exception) { Console.WriteLine(exception.Message); } } }
public void Add(int orderId, string activityName, decimal laborPrice) { var activity = new Activity() { OrderId = orderId, Name = activityName, LaborPrice = laborPrice }; using (var context = new WorkschopContext()) { try { context.Activities.Add(activity); context.SaveChanges(); } catch (Exception exception) { Console.WriteLine(exception.Message); } } }