public async Task <bool> StoreNewReservation(ReservationDataModel model) { var reservationModel = _mapper.Map <ReservationInfo>(model); //var counter = _context.ReservationInfos.Count() reservationModel.BookingReferenceId = ""; using (Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = _context.Database.BeginTransaction()) { await _context.ReservationInfos.AddAsync(reservationModel); await _context.SaveChangesAsync(); foreach (var item in model.OptionalServicesList) { await _context.AdditionalServiceTakens.AddAsync(new AdditionalServicesTaken() { NoOfTimes = item.NoOfTimes, ReservationInfoId = reservationModel.Id, Created = DateTime.Now, AdditionalServiceRateId = item.AdditionlServiceRateId }); } if (model.OptionalServicesList.Count() > 0) { await _context.SaveChangesAsync(); } transaction.Commit(); } if (reservationModel.Id > 0) { return(true); } return(false); }
public async Task CreateReservation(ReservationInputModel input) { var flight = await this.db.Flights.FirstOrDefaultAsync(f => f.Id == input.FlightId); if (flight == null) { throw new ArgumentException("Invalid flight!"); } var reservation = new ReservationDataModel() { FirstName = input.FirstName, MiddleName = input.MiddleName, LastName = input.LastName, EGN = input.EGN, Nationality = input.Nationality, TelNumber = input.TelNumber, TicketType = input.TicketType, Flight = flight, FlightId = flight.Id, }; flight.Reservations.Add(reservation); await this.db.Reservations.AddAsync(reservation); await this.db.SaveChangesAsync(); }
public async Task <IActionResult> Edit(int?id, ReservationDataModel reservationDataModel) { if (id != reservationDataModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(reservationDataModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReservationDataModelExists(reservationDataModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(reservationDataModel)); }
public async Task <Boolean> Booking([FromBody] ReservationDataModel dataModel) { if (ModelState.IsValid) { var result = await _reservationInfosRepo.StoreNewReservation(dataModel); return(result); } return(false); }
static void Main(string[] args) { var searchItems = new List<FilterItem>(); ReservationDataModel gridModel = new ReservationDataModel(); IQueryable queryableSource = gridModel.GetRawData(searchItems); int PageCount, pageIndex = 0; dynamic data = gridModel.SelectDataForDataModel( queryableSource, searchItems, pageIndex, out PageCount); }
public ReservationViewModel MapToViewModel(ReservationDataModel model) { return(new ReservationViewModel() { name = model.name, surname = model.surname, isActive = model.isActive, rideId = model.rideId }); }
static void Main(string[] args) { var searchItems = new List <FilterItem>(); ReservationDataModel gridModel = new ReservationDataModel(); IQueryable queryableSource = gridModel.GetRawData(searchItems); int PageCount, pageIndex = 0; dynamic data = gridModel.SelectDataForDataModel( queryableSource, searchItems, pageIndex, out PageCount); }
public async Task <IActionResult> Create(ReservationDataModel reservationDataModel) { if (ModelState.IsValid) { _context.Add(reservationDataModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(reservationDataModel)); }