Exemplo n.º 1
0
 /// <summary>
 /// Remove OrderPayment from the database
 /// </summary>
 /// <param name="orderPayment"></param>
 /// <param name="db"></param>
 public static void RemoveOrderPayment(OrderPaymentModel orderPayment, string db)
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnVal(db)))
     {
         var p = new DynamicParameters();
         p.Add("@Id", orderPayment.Id);
         connection.Execute("dbo.spOrderPayment_Delete", p, commandType: CommandType.StoredProcedure);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Search in all orders to find the OrderPayment Then return the Order
        /// </summary>
        /// <param name="orderPayment"></param>
        /// <returns></returns>
        public static OrderModel GetTheOrder(OrderPaymentModel orderPayment)
        {
            foreach (OrderModel order in PublicVariables.Orders)
            {
                OrderPaymentModel orderPaymentModel;
                orderPaymentModel = order.OrderPayments.Find(x => x == orderPayment);

                if (orderPaymentModel != null)
                {
                    return(order);
                }
            }
            return(null);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Add OrderPayment to the database
 /// Get the orderPayment with the new ID
 /// </summary>
 /// <param name="orderPayment"></param>
 /// <param name="order"></param>
 /// <param name="db"></param>
 /// <returns></returns>
 public static OrderPaymentModel AddOrderPaymentToTheDatabase(OrderPaymentModel orderPayment, OrderModel order, string db)
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnVal(db)))
     {
         var p = new DynamicParameters();
         p.Add("@OrderId", order.Id);
         p.Add("@StaffId", orderPayment.Staff.Id);
         p.Add("@StoreId", orderPayment.Store.Id);
         p.Add("@Paid", orderPayment.Paid);
         p.Add("@Date", orderPayment.Date);
         p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);
         connection.Execute("dbo.spOrderPayment_Create", p, commandType: CommandType.StoredProcedure);
         orderPayment.Id = p.Get <int>("@Id");
     }
     return(orderPayment);
 }