Пример #1
0
        //Create List to store your CSV data
        public List<Models.Booking> parseBookings()
        {
            CsvReader csv = new CsvReader(reader, true);
            int fieldCount = csv.FieldCount;
            List<Booking> bookinglist = new List<Booking>();

            String[] headers = csv.GetFieldHeaders();

            while (csv.ReadNextRecord())
            {
                Booking exObj = new Booking();

                for (int i = 0; i < fieldCount; i++)
                {
                    if (headers[i].Equals("holidayhomeno")) { exObj.holidayhomeno = csv[i]; }
                    else if (headers[i].Equals("customername")) { exObj.customername = csv[i]; }
                    else if (headers[i].Equals("address")) { exObj.address = csv[i]; }
                    else if (headers[i].Equals("price")) { exObj.price = csv[i]; }
                    else if (headers[i].Equals("startdate")) { exObj.startdate = csv[i]; }
                    else if (headers[i].Equals("enddate")) { exObj.enddate = csv[i]; }
                    else if (headers[i].Equals("creditcardtype")) { exObj.creditcardtype = csv[i]; }
                    else if (headers[i].Equals("expirydate")) { exObj.expirydate = csv[i]; }
                }

                bookinglist.Add(exObj);
            }

            return bookinglist;
        }
Пример #2
0
        public bool addBookingDb(Booking bok)
        {
            Booking book = new Booking();
            try
            {
                book = db.Bookings.Add(bok);
            }

            catch (Exception exp)
            {

                Exception j = exp;
                return false;

            }

            if (bok is Booking)
            {
                db.SaveChanges();
                return true;
            }
            return false;
        }
Пример #3
0
 public bool updateBookingDb(Booking bok)
 {
     db.Entry(bok).State = EntityState.Modified;
     db.SaveChanges();
     return true;
 }