public static double RedeemOrNot(OrderDetailsFormViewModel viewModel, Customer customer, ApplicationDbContext _context) { if (viewModel.RedeemBonus) { return(MemberCard.GetNewTotalCost(GetTotalCost(viewModel.Prices, viewModel.Quantities, viewModel.Count, viewModel.AddToCarts), MemberCard.BonusAmount(customer, _context))); } else { return(GetTotalCost(viewModel.Prices, viewModel.Quantities, viewModel.Count, viewModel.AddToCarts)); } }
public static void CheckMembershipType(MemberCard memberCard, int credits, ApplicationDbContext _context) { if (credits >= 1000 && credits <= 5000) { memberCard.Type = MembershipType.Silver; } else if (credits > 5000) { memberCard.Type = MembershipType.Gold; } else { memberCard.Type = MembershipType.Basic; } _context.SaveChanges(); }
public static OrderDetailsFormViewModel FillOrderDetailsViewModel(OrderFormViewModel viewModel, Customer customer, ApplicationDbContext _context) { OrderDetailsFormViewModel detailsViewmodel = new OrderDetailsFormViewModel(); for (int i = 0; i < viewModel.Count; i++) { detailsViewmodel.ProductStockIds.Add(viewModel.ProductStockIds[i]); detailsViewmodel.Quantities.Add(viewModel.Quantities[i]); detailsViewmodel.AddToCarts.Add(viewModel.AddToCarts[i]); detailsViewmodel.Prices.Add(viewModel.Prices[i]); detailsViewmodel.ProductNames.Add(viewModel.ProductNames[i]); detailsViewmodel.SubTotal.Add(GetSubTotal(viewModel.Prices[i], viewModel.Quantities[i])); } detailsViewmodel.OrderNumber = GetOrderNumber(customer.CustomerID, _context); detailsViewmodel.TotalCost = GetTotalCost(viewModel.Prices, viewModel.Quantities, viewModel.Count, viewModel.AddToCarts); detailsViewmodel.OrderDate = customer.GetCreationDate(); detailsViewmodel.Count = viewModel.Count; detailsViewmodel.OrderId = viewModel.OrderId; detailsViewmodel.FirstName = customer.FirstName; detailsViewmodel.LastName = customer.LastName; detailsViewmodel.City = customer.City; detailsViewmodel.Country = customer.Country; detailsViewmodel.Address = customer.Address; detailsViewmodel.CustomerId = customer.CustomerID; detailsViewmodel.PhoneNumber = customer.PhoneNumber; detailsViewmodel.PostalCode = customer.PostalCode; detailsViewmodel.Email = customer.Email; detailsViewmodel.PaymentType = PaymentType.none; // TODO detailsViewmodel.IfBonusIsApplicable = MemberCard.CheckBonus(detailsViewmodel.TotalCost, customer, _context); detailsViewmodel.CartIsEmpty = false; return(detailsViewmodel); }
public static double GetTotalCostAfterMemberShipBonus(List <double> Price, List <int> Quantity, int Count, List <bool> Bought, MemberCard memberCard) { double TotalCost = 0; switch (memberCard.Type) { case MembershipType.Silver: TotalCost = GetTotalCost(Price, Quantity, Count, Bought) - 20; break; case MembershipType.Gold: TotalCost = GetTotalCost(Price, Quantity, Count, Bought) - 30; break; case MembershipType.Basic: TotalCost = GetTotalCost(Price, Quantity, Count, Bought) - 10; break; } return(TotalCost); }
public static DateTime GetCreationDate() { MemberCard memberCard = new MemberCard(); return(memberCard.CreationDate = DateTime.Now); }