public RevenueApprovalStatus?BacktrackWorkflowAll(DateTime month, string propertyCode, RevenueApprovalStatus state) { try { var reservationProvider = new ReservationProvider(_context); DateTime startDate = new DateTime(month.Year, month.Month, 1); DateTime endDate = new DateTime(month.Year, month.Month, DateTime.DaysInMonth(month.Year, month.Month)); var reservations = reservationProvider.Retrieve(startDate, endDate, propertyCode); var prevState = PrevState(state); if (reservations != null && prevState != null) { foreach (var reservation in reservations) { if (reservation.ApprovalStatus >= prevState) { reservation.ApprovalStatus = prevState.Value; RetrackWorkflowSignature(reservation, state); reservationProvider.Update(reservation.ReservationId, reservation); } } reservationProvider.Commit(); return(prevState); } } catch { throw; } return(null); }
public override void Update(int id, ReservationRevenueModel model) { try { ReservationProvider reservationProvider = new ReservationProvider(_context); Reservation entity = reservationProvider.Retrieve(model.ReservationId); MapData(model, entity, false); reservationProvider.Update(id, entity); } catch { throw; } }
public override void Create(ReservationRevenueModel model) { try { ReservationProvider dataProvider = new ReservationProvider(_context); var entity = new Reservation(); MapData(model, entity, true); dataProvider.Create(entity); } catch { throw; } }
public override void Delete(int id) { try { // revenue reservation deletion does not physically delete the record; it marks [IsDeletd] = true ReservationProvider reservationProvider = new ReservationProvider(_context); Reservation reservation = reservationProvider.Retrieve(id); reservation.IsDeleted = true; reservationProvider.Update(id, reservation); } catch { throw; } }
public RevenueApprovalStatus?BacktrackWorkflow(int reservationId, RevenueApprovalStatus state) { try { var reservationProvider = new ReservationProvider(_context); var reservation = reservationProvider.Retrieve(reservationId); var prevState = PrevState(state); if (reservation != null && prevState != null) { reservation.ApprovalStatus = prevState.Value; RetrackWorkflowSignature(reservation, state); reservationProvider.Update(reservationId, reservation); reservationProvider.Commit(); return(prevState); } } catch { throw; } return(null); }
public RevenueApprovalStatus?MoveWorkflow(int reservationId, RevenueApprovalStatus state) { try { var reservationProvider = new ReservationProvider(_context); var reservation = reservationProvider.Retrieve(reservationId); var nextState = NextState(state); if (reservation != null && nextState != null) { reservation.ApprovalStatus = state; SetWorkflowSignature(reservation, state); reservationProvider.Update(reservationId, reservation); reservationProvider.Commit(); return(nextState); } } catch { throw; } return(null); }
public bool SetFieldStatus(int reservationId, string fieldname, double taxrate, bool included) { try { var reservationProvider = new ReservationProvider(_context); var reservation = reservationProvider.Retrieve(reservationId); if (reservation != null) { if (fieldname == "IncludeOnStatement") { reservation.IncludeOnStatement = included; } else if (fieldname == "IsTaxed") { reservation.TaxRate = (float)taxrate; reservation.IsTaxed = included; UpdateTotalRevenue(reservation); } else if (fieldname == "IsFutureBooking") { reservation.IsFutureBooking = included; } else // not supported field; just ignore for now... { return(true); } reservationProvider.Update(reservation.ReservationId, reservation); reservationProvider.Commit(); return(true); } } catch { throw; } return(false); }