public static List <object> ViewTblGetComboBoxObjects(dynamic user) { var Transaction = new Transaction(); var PastReservation = new PastReservation(); var CurrentDelivery = new CurrentDelivery(); var PastDelivery = new PastDelivery(); var Item = new Item(); var Supplier = new Supplier(); var datasource = new List <object> { Transaction, PastReservation, CurrentDelivery, PastDelivery, Item, Supplier }; //if user isn't an admin and isnt allowed to see analytics //then remove first item from datasouce (transactions) if (!(user.IsAnalyticsAllowed)) { //if the user isnt an admi datasource.RemoveAt(0); } return(datasource); }
public async Task <IActionResult> PayBillConfirmed([Bind("TotalPrice,Tip,Id")] Reservation reservation) { var reservationFromDb = await _context.Reservations.FindAsync(reservation.Id); var pastReservation = new PastReservation(); pastReservation.ReservationId = reservationFromDb.Id; reservationFromDb.TotalPrice = reservation.TotalPrice; reservationFromDb.Tip = ((Convert.ToDecimal(reservation.TotalPrice) * 20) / 100).ToString(); reservationFromDb.IsPayed = true; if (ModelState.IsValid) { _context.Update(reservationFromDb); _context.Add(pastReservation); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); }