public void IsPromoUsed_Test() { //arrange //act PromoCode promo = new PromoCode(2); //assert Assert.True(promo.IsUsed(new Rider(10))); }
public ActionResult OrderUser(string promo, int cartId) { try { Buyer b = new Account(User.Identity.GetUserId()).Buyer; Cart c = new Cart(cartId); Order o; if (promo == null || promo == "") { o = new Order(c, DateTime.Now); c.IsCurrent = false; } else { PromoCode p = new PromoCode(promo); if (p.IsUsed(b.GetAccount())) { return(RedirectToAction("Index", new { promoValidation = true })); } o = new Order(c, DateTime.Now, p); c.IsCurrent = false; } OrderSuccessViewModel osvm = new OrderSuccessViewModel() { BuyersName = b.Name, DeliveryCharges = decimal.Round(b.City.DeliverCharges).ToString(), DiscountAvailed = o.Promo.Discount + "%", OrderId = o.OrderId.ToString(), Status = o.Status, TotalPrice = decimal.Round(o.TotalPrice).ToString() }; return(View("OrderSuccess", osvm)); } catch (Exception ex) { HandleErrorInfo error = new HandleErrorInfo(ex, "Cart", "OrderUser"); return(RedirectToAction("Index", "Error", new { model = error })); } }