コード例 #1
0
 public LoyaltyCardViewModel(LoyaltyCard loyaltyCard)
 {
     this.Guid = loyaltyCard.Guid;
     this.Number = loyaltyCard.Number;
     this.Discount = loyaltyCard.Discount;
     this.LoyaltyCardType = loyaltyCard.LoyaltyCardType;
     this.DateCreated = loyaltyCard.DateCreated;
     this.DateConsumed = loyaltyCard.DateConsumed;
     this.Status = loyaltyCard.Status;
     this.Title = loyaltyCard.Title;
     this.OrderGuid = loyaltyCard.OrderGuid;
 }
コード例 #2
0
        public ActionResult Save(LoyaltyCardViewModel viewModel)
        {
            if (this.ModelState.IsValid)
            {
                LoyaltyCard loyaltyCard = this._queryDispatcher.Dispatch<LoyaltyCard, GetLoyaltyCardByGuidQuery>(new GetLoyaltyCardByGuidQuery(viewModel.Guid));

                if (loyaltyCard == null)
                {
                    loyaltyCard = new LoyaltyCard(viewModel.Guid);
                }

                loyaltyCard.Number = viewModel.Number;
                loyaltyCard.Discount = viewModel.Discount.Value;
                loyaltyCard.LoyaltyCardType = viewModel.LoyaltyCardType.Value;
                loyaltyCard.Title = viewModel.Title;

                this._commandDispatcher.Dispatch(new SaveLoyaltyCardCommand(loyaltyCard));

                return this.RedirectToRoute(Routes.LoyaltyCards.Edit, new { guid = viewModel.Guid, saved = true });
            }

            return this.RedirectToRoute(Routes.LoyaltyCards.Edit, new { guid = viewModel.Guid });
        }
コード例 #3
0
        public void SaveLoyaltyCard(LoyaltyCard loyaltyCard)
        {
            if (this.GetLoyaltyCardByGuid(loyaltyCard.Guid) == null)
            {
                // insert
                string sql = "Insert Into VintageRabbit.LoyaltyCards (Guid, Number, Title, Discount, Status, DateCreated, DateConsumed, OrderGuid, LoyaltyCardType, Cost) Values (@Guid, @Number, @Title, @Discount, @Status, @DateCreated, @DateConsumed, @OrderGuid, @LoyaltyCardType, @Cost)";
                using (SqlConnection connection = new SqlConnection(this._connectionString))
                {
                    connection.Execute(sql, new
                    {
                        Guid = loyaltyCard.Guid,
                        Number = loyaltyCard.Number,
                        Title = loyaltyCard.Title,
                        Discount = loyaltyCard.Discount,
                        Cost = loyaltyCard.Cost,
                        Status = loyaltyCard.Status.ToString(),
                        DateCreated = DateTime.Now,
                        DateConsumed = loyaltyCard.DateConsumed,
                        OrderGuid = loyaltyCard.OrderGuid,
                        LoyaltyCardType = loyaltyCard.LoyaltyCardType

                    });
                }
            }
            else
            {
                //update
                string sql = @"Update VintageRabbit.LoyaltyCards Set Number = @Number, Title = @Title, Discount = @Discount, Status = @Status, DateConsumed = @DateConsumed, OrderGuid = @OrderGuid, LoyaltyCardType= @LoyaltyCardType, Cost = @Cost Where Guid = @Guid";

                using (SqlConnection connection = new SqlConnection(this._connectionString))
                {
                    connection.Execute(sql, new
                    {
                        Guid = loyaltyCard.Guid,
                        Number = loyaltyCard.Number,
                        Title = loyaltyCard.Title,
                        Discount = loyaltyCard.Discount,
                        Cost = loyaltyCard.Cost,
                        Status = loyaltyCard.Status.ToString(),
                        DateCreated = DateTime.Now,
                        DateConsumed = loyaltyCard.DateConsumed,
                        OrderGuid = loyaltyCard.OrderGuid,
                        LoyaltyCardType = loyaltyCard.LoyaltyCardType
                    });
                }
            }
        }
コード例 #4
0
ファイル: Order.cs プロジェクト: Brontsy/Vintage-Rabbit
        internal void AddloyaltyCard(LoyaltyCard loyaltyCard)
        {
            if(this.Items.Any(o => o.Product.Type == Common.Enums.ProductType.Discount))
            {
                this.Items.Remove(this.Items.First(o => o.Product.Type == Common.Enums.ProductType.Discount));
            }

            this.Items.Add(new OrderItem(loyaltyCard));
        }
コード例 #5
0
ファイル: OrderItem.cs プロジェクト: Brontsy/Vintage-Rabbit
 public OrderItem(LoyaltyCard loyaltyCard)
     : this()
 {
     this.Product = loyaltyCard;
     this.Quantity = 1;
 }