コード例 #1
0
        public bool SaveCustomerDetails(Customer customer) // calling SaveStudentMethod for insert a new record
        {
            bool result = false;

            using (CustomerEntities _entity = new CustomerEntities())
            {
                _entity.Customer.Add(customer);
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
        public bool DeleteFlightDetails(Flight flight) // DeleteStudentDetails method to delete record from table
        {
            bool result = false;

            using (CustomerEntities _entity = new CustomerEntities())
            {
                //Flight book = (Flight)_entity.Flight.Where(b => b.flightId == flight.flightId).First();
                //_entity.DeleteObject(book);
                Flight _flight = _entity.Flight.Where(x => x.flightId == flight.flightId).Select(x => x).FirstOrDefault();
                _entity.Flight.Remove(_flight);
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
        public bool UpdateFlightDetails(Flight flight) // UpdateStudentDetails method for update a existing Record
        {
            bool result = false;

            using (CustomerEntities _entity = new CustomerEntities())
            {
                Flight _flight = _entity.Flight.Where(x => x.flightId == flight.flightId).Select(x => x).FirstOrDefault();
                _flight.airlineCompany = flight.airlineCompany;
                _flight.origin         = flight.origin;
                _flight.destination    = flight.destination;
                _flight.date           = flight.date;
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }