public static List <PnPViewModel> GetAllPackages() { TravelExpertsContext context = new TravelExpertsContext(); var query = from packages in context.Packages orderby packages.PkgStartDate select new PnPViewModel { PkgName = packages.PkgName, ProdName = null, SupName = null, Destination = null, TripStart = packages.PkgStartDate, TripEnd = packages.PkgEndDate, BasePrice = packages.PkgBasePrice, FeeName = "Booking Charge", FeeAmt = 25.0m, TotalPrice = packages.PkgBasePrice + 25 }; List <PnPViewModel> displayedPackgesList = new List <PnPViewModel>(); foreach (PnPViewModel package in query) { displayedPackgesList.Add(package); } return(displayedPackgesList); }
public static void Add(Customer c) { var context = new TravelExpertsContext(); context.Customers.Add(c); context.SaveChanges(); }
public static CustomersAuthentication GetByCustomerId(int id) { var context = new TravelExpertsContext(); var cust = context.CustomersAuthentications.SingleOrDefault(c => c.CustomerId == id); return(cust); }
public static ClaimsModel Authenticate(string username, string password) { TravelExpertsContext context = new TravelExpertsContext(); var user = context.CustomersAuthentications.SingleOrDefault(usr => usr.Username == username && usr.Password == password); if (user != null) { int customerId = user.CustomerId; var customer = context.Customers.SingleOrDefault(cust => cust.CustomerId == customerId); string fName = customer.CustFirstName; ClaimsModel claims = new ClaimsModel() { Username = username, CustomerId = customerId, CustFirstName = fName }; return(claims); } else { return(null); } }
public static Customer GetAuthenticatedCustomerByID(int id) { var context = new TravelExpertsContext(); var cust = context.Customers.Include(ca => ca.CustomersAuthentication).SingleOrDefault(c => c.CustomerId == id); return(cust); }
public static List <PnPViewModel> GetAllProductsDisplayed() { TravelExpertsContext context = new TravelExpertsContext(); var query = from products in context.ProductsDisplayeds orderby products.TripStart select new PnPViewModel { PkgName = null, ProdName = products.ProdName, SupName = products.SupName, Destination = products.Destination, TripStart = products.TripStart, TripEnd = products.TripEnd, BasePrice = products.BasePrice, FeeName = products.FeeName, FeeAmt = products.FeeAmt, TotalPrice = products.BasePrice.GetValueOrDefault(0) + products.FeeAmt.GetValueOrDefault(0) }; List <PnPViewModel> displayedProductsList = new List <PnPViewModel>(); foreach (PnPViewModel product in query) { displayedProductsList.Add(product); } return(displayedProductsList); }
public static List <Customer> Registration() { var context = new TravelExpertsContext(); var customers = context.Customers.Include(c => c.CustomersAuthentication).ToList(); return(customers); }
public static List <PurchaseModel> GetPurchasedPackages(int customerId) { TravelExpertsContext context = new TravelExpertsContext(); var query = from bookings in context.Bookings join bookingDetails in context.BookingDetails on bookings.BookingId equals bookingDetails.BookingId where bookings.CustomerId == customerId where bookingDetails.ProdName == null select new PurchaseModel { BookingDetailId = bookingDetails.BookingDetailId, BookingNo = bookings.BookingNo, PkgName = bookingDetails.PkgName, ProdName = bookingDetails.ProdName, SupName = bookingDetails.SupName, Destination = bookingDetails.Destination, TripStart = bookingDetails.TripStart, TripEnd = bookingDetails.TripEnd, TotalPrice = (decimal)(bookingDetails.BasePrice + bookingDetails.FeeAmt), IsPaid = bookingDetails.IsPaid }; List <PurchaseModel> purchasedPackageList = new List <PurchaseModel>(); foreach (PurchaseModel package in query) { purchasedPackageList.Add(package); } return(purchasedPackageList); }
public static void RequestRefund(int bookingDetailsId) { TravelExpertsContext context = new TravelExpertsContext(); var target = (from bookingDetails in context.BookingDetails where bookingDetails.BookingDetailId == bookingDetailsId select bookingDetails).SingleOrDefault(); target.IsPaid = "REFUND REQUESTED"; context.SaveChanges(); }
public static bool SecurityQuestionAnsweredCorrect(string username, string answer) { TravelExpertsContext context = new TravelExpertsContext(); CustomersAuthentication target = context.CustomersAuthentications.SingleOrDefault(c => c.Username == username); if (target.SQAnswer1 == answer) { return(true); } else { return(false); } }
public static bool UsernameIsTaken(string user) { var context = new TravelExpertsContext(); var ca = context.CustomersAuthentications.ToList(); var usernames = ca.Select(a => a.Username).Distinct(); if (usernames.Contains(user, StringComparer.OrdinalIgnoreCase)) { return(true); } else { return(false); } }
public static bool CheckOldPasswordThenUpdate(int id, string user, string oldp, string newp) { var context = new TravelExpertsContext(); var u = context.CustomersAuthentications.SingleOrDefault(cp => cp.CustomerId == id); if (u.Password == oldp) { u.Username = user; u.Password = newp; /*u.Password = confnewp*/; context.SaveChanges(); return(true); } else { return(false); } }
public static void DeleteOrder(int bookingDetailsId) { TravelExpertsContext context = new TravelExpertsContext(); var target = from bookingDetails in context.BookingDetails where bookingDetails.BookingDetailId == bookingDetailsId select bookingDetails; List <BookingDetail> list = new List <BookingDetail>(); foreach (BookingDetail deet in target) { list.Add(deet); } context.BookingDetails.Remove(list[0]); context.SaveChanges(); }
public static void Update(int id, Customer c) { var context = new TravelExpertsContext(); var u = context.Customers.SingleOrDefault(cp => cp.CustomerId == id); u.CustFirstName = c.CustFirstName; u.CustLastName = c.CustLastName; u.CustAddress = c.CustAddress; u.CustCity = c.CustCity; u.CustProv = c.CustProv; u.CustPostal = c.CustPostal; u.CustHomePhone = c.CustHomePhone; u.CustBusPhone = c.CustBusPhone; u.CustFax = c.CustFax; u.CustEmail = c.CustEmail; context.SaveChanges(); }
public static string GetSecurityQuestion(string username) { TravelExpertsContext context = new TravelExpertsContext(); CustomersAuthentication target = context.CustomersAuthentications.SingleOrDefault(c => c.Username == username); string question; if (target == null) { question = null; } else { question = target.SecurityQuestion1; } return(question); }
public static decimal GetTotalOwing(int customerId) { decimal unpaidBasePrices; decimal unpaidFees; TravelExpertsContext context = new TravelExpertsContext(); var uBP = (from bookings in context.Bookings join bookingDetails in context.BookingDetails on bookings.BookingId equals bookingDetails.BookingId where bookings.CustomerId == customerId where bookingDetails.IsPaid == "NO" select bookingDetails.BasePrice).Sum(); if (uBP == null) { unpaidBasePrices = 0; } else { unpaidBasePrices = uBP.Value; } var uF = (from bookings in context.Bookings join bookingDetails in context.BookingDetails on bookings.BookingId equals bookingDetails.BookingId where bookings.CustomerId == customerId where bookingDetails.IsPaid == "NO" select bookingDetails.FeeAmt).Sum(); if (uF == null) { unpaidFees = 0; } else { unpaidFees = uF.Value; } decimal unpaidTotal = unpaidBasePrices + unpaidFees; return(unpaidTotal); }
public static void AddProductOrder(int customerId, string prodName, string supName, string destination, decimal basePrice, string feeName, decimal feeAmt, DateTime tripStart, DateTime tripEnd) { TravelExpertsContext context = new TravelExpertsContext(); Booking booking = new Booking { BookingDate = null, BookingNo = BookingNoGenerator.GenerateBookingNo(), CustomerId = customerId, PackageId = 1, TripTypeId = "B", TravelerCount = null }; context.Bookings.Add(booking); context.SaveChanges(); BookingDetail bookingDetail = new BookingDetail { ItineraryNo = null, TripStart = tripStart, TripEnd = tripEnd, Description = null, Destination = destination, BasePrice = basePrice, AgencyCommission = null, BookingId = booking.BookingId, Region = null, Class = null, FeeName = feeName, FeeAmt = feeAmt, ProdName = prodName, SupName = supName, PkgName = null, IsPaid = "NO" }; context.BookingDetails.Add(bookingDetail); context.SaveChanges(); }
public EditModel(Group8.TravelExperts.Data.Domain.TravelExpertsContext context) { _context = context; }