public Car Create(string brand, string modelName, int year)
        {
            Car car = new Car(brand, modelName, year);

            _carsDbContext.CarList.Add(car);

            if (_carsDbContext.SaveChanges() > 0)
            {
                return(car);
            }

            return(null);
        }
Beispiel #2
0
        public Insurance Create(string name, double price)
        {
            Insurance insurance = new Insurance()
            {
                Name = name, Price = price
            };

            _carsDbContext.Insurances.Add(insurance);

            if (_carsDbContext.SaveChanges() > 0)
            {
                return(insurance);
            }

            return(null);
        }
        public Sale Create(string buyer, string seller, Car car, DateTime transactionDate)
        {
            Sale sale = new Sale()
            {
                Car = car, Buyer = buyer, Seller = seller, TransactionDate = transactionDate
            };

            _carsDbContext.Sales.Add(sale);

            if (_carsDbContext.SaveChanges() > 0)// don´t forget to save
            {
                return(sale);
            }
            else
            {
                return(null);
            }
        }