当前位置: 首页>>代码示例>>C#>>正文


C# Purchase类代码示例

本文整理汇总了C#中Purchase的典型用法代码示例。如果您正苦于以下问题:C# Purchase类的具体用法?C# Purchase怎么用?C# Purchase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Purchase类属于命名空间,在下文中一共展示了Purchase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePurchase

        public IHttpActionResult CreatePurchase(int id)
        {
            var userId = this.User.Identity.GetUserId();

            var book = this.Data.Books.Read().FirstOrDefault(b => b.Id == id);

            if (book == null)
            {
                return this.NotFound();
            }

            if (book.Copies == 0)
            {
                return this.BadRequest("There are no copies left.");
            }

            var purchase = new Purchase
                               {
                                   UserId = userId, 
                                   Book = book, 
                                   Price = book.Price, 
                                   DateOfPurchase = DateTime.Now, 
                                   IsRecalled = false
                               };

            this.Data.Purchases.Create(purchase);
            book.Copies--;
            this.Data.SaveChanges();

            return this.Ok("Your purchase number is: " + purchase.Id);
        }
开发者ID:iliankostov,项目名称:WebServicesAndCloud,代码行数:31,代码来源:PurchaseController.cs

示例2: Main

 static void Main(string[] args)
 {
     //объявление и инициализация массива
     Purchase[] purchases = new Purchase[]
     {
         new Purchase("cup",38000,3,Days.Mon),
         new Purchase("plate",50000,1,Days.Sun),
         new Purchase("spoon",21000,4,Days.Wed),
         new Purchase("fork",12000,4,Days.Fri),
         new Purchase("knife",35000,2,Days.Sat),
     };
     double sum = 0; // переменная для нахождения суммы покупок
     for (int i = 0; i < purchases.Length; i++)
     {
         if (purchases[i] != null)
         {
             Console.WriteLine(purchases[i]);
             sum = sum + purchases[i].GetCost();
         }
     }
     Array.Sort(purchases);
     Console.WriteLine("\nСредняя стоимость всех покупок "+(sum/purchases.Length));
     Console.WriteLine("День самой дорогой покупки " + purchases[0].Days+"\n");
     for (int i = 0; i < purchases.Length; i++)
     {
         if (purchases[i] != null)
             Console.WriteLine(purchases[i]);
     }
     Console.ReadKey();
 }
开发者ID:Taturevich,项目名称:1_3,代码行数:30,代码来源:Program.cs

示例3: ViewEditPurchaseView

 public ViewEditPurchaseView(Purchase thisPurchase)
 {
     InitializeComponent();
     _currentPurchase = thisPurchase;
     this.Text = string.Format("Purchase No. {0:0000}", _currentPurchase);
     InitializeThings();
 }
开发者ID:titusxp,项目名称:buzzle,代码行数:7,代码来源:ViewEditPurchaseView.cs

示例4: EntitiesTest

    public void EntitiesTest()
    {
      Purchase purchase = new Purchase() { Id = 1 };
      purchase.PurchaseLine.Add(new PurchaseLine() { Id = 1, Purchase = purchase });
      purchase.PurchaseLine.Add(new PurchaseLine() { Id = 2, Purchase = purchase });

      StringWriter sw = new StringWriter();
      JsonSerializer serializer = new JsonSerializer();
      serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;

      using (JsonWriter jw = new JsonTextWriter(sw))
      {
        jw.Formatting = Formatting.Indented;

        serializer.Serialize(jw, purchase);
      }

      string json = sw.ToString();

      Assert.AreEqual(@"{
  ""Id"": 1,
  ""PurchaseLine"": [
    {
      ""Id"": 1,
      ""PurchaseReference"": {
        ""EntityKey"": null,
        ""RelationshipName"": ""EntityDataModel.PurchasePurchaseLine"",
        ""SourceRoleName"": ""PurchaseLine"",
        ""TargetRoleName"": ""Purchase"",
        ""RelationshipSet"": null,
        ""IsLoaded"": false
      },
      ""EntityState"": 1,
      ""EntityKey"": null
    },
    {
      ""Id"": 2,
      ""PurchaseReference"": {
        ""EntityKey"": null,
        ""RelationshipName"": ""EntityDataModel.PurchasePurchaseLine"",
        ""SourceRoleName"": ""PurchaseLine"",
        ""TargetRoleName"": ""Purchase"",
        ""RelationshipSet"": null,
        ""IsLoaded"": false
      },
      ""EntityState"": 1,
      ""EntityKey"": null
    }
  ],
  ""EntityState"": 1,
  ""EntityKey"": null
}", json);

      Purchase newPurchase = JsonConvert.DeserializeObject<Purchase>(json);
      Assert.AreEqual(1, newPurchase.Id);

      Assert.AreEqual(2, newPurchase.PurchaseLine.Count);
      Assert.AreEqual(1, newPurchase.PurchaseLine.ElementAt(0).Id);
      Assert.AreEqual(2, newPurchase.PurchaseLine.ElementAt(1).Id);
    }
开发者ID:bitpusher,项目名称:Newtonsoft.Json4,代码行数:60,代码来源:JsonConvertTest.cs

示例5: CreateFromSku

 public static Purchase CreateFromSku(string sku, string developerPayload)
 {
     var p = new Purchase();
     p.Sku = sku;
     p.DeveloperPayload = developerPayload;
     return p;
 }
开发者ID:tracer8,项目名称:OpenIAB-angrybots,代码行数:7,代码来源:Purchase.cs

示例6: AddPurchase

        public ActionResult AddPurchase(int id)
        {
            Purchase purchase = new Purchase();
            {
                purchase.CreateDate = DateTime.Now;
                purchase.Id = 1;
            }

            decimal k = 0;

            //foreach (var find in products)
            //{

            //    //if (find.CartId == id)
            //    //{

            //    //    k = k + find.Price;

            //    //}

            //}
            //purchase.TotalPrice = k;
            //purchases.Add(purchase);

            return View(purchase);
        }
开发者ID:begum88,项目名称:damacana,代码行数:26,代码来源:HomeController.cs

示例7: HandlerOnOnPurchaseFailedValidation

 private static void HandlerOnOnPurchaseFailedValidation(Purchase purchase, string purchaseData, string purchaseSignature)
 {
     var message = string.Format("Id={0}, developerPayload={1}, state={2}, orderId={3}, time={4}, data={5}", 
         purchase.ProductId, purchase.DeveloperPayload, purchase.PurchaseState,
         purchase.OrderId, purchase.PurchaseTime, purchaseData);
     GaService.TrackAppException("Extensions", "HandlerOnOnPurchaseFailedValidation", string.Empty, message, false);
 }
开发者ID:okrotowa,项目名称:Mosigra.Yorsh,代码行数:7,代码来源:BillingErrorExtensions.cs

示例8: BasicPurchase

        public ReceiptModel BasicPurchase(RequestModel model)
        {
            OrderInfo oinfo = new OrderInfo();

            string host = AuthInfo.Host;
            string store_id = AuthInfo.StoreID;
            string api_token = AuthInfo.APIToken;
            string order_id = oinfo.GenerateOrderID();// "Test_P_0333";
            string amount = model.Amount.Value.ToString();
            string pan = model.PAN;// "4242424242424242";
            string expdate = model.ExpDate.ToString();//"0812";
            string crypt = model.Crypt;// "7";
            //string status = "true";

            /* Status Check Example */
            //  HttpsPostRequest mpgReq =
            //    new HttpsPostRequest(host, store_id, api_token, status,
            //               new Purchase(order_id, amount, pan, expdate, crypt));

            Purchase purchase = new Purchase(order_id, amount, pan, expdate, crypt);

            //purchase.SetDynamicDescriptor("2134565");

            HttpsPostRequest mpgReq =
                  new HttpsPostRequest(host, store_id, api_token, purchase);
            ReceiptModel rcptModel = new ReceiptModel();
            try
            {
                Receipt receipt = mpgReq.GetReceipt();

                rcptModel.CardType = receipt.GetCardType();
                rcptModel.TransAmount =receipt.GetTransAmount();
                rcptModel.TxnNumber = receipt.GetTxnNumber();
                rcptModel.ReceiptId = receipt.GetReceiptId();
                rcptModel.TransType = receipt.GetTransType();
                rcptModel.ReferenceNum = receipt.GetReferenceNum();
                rcptModel.ResponseCode = receipt.GetResponseCode();
                rcptModel.ISO = receipt.GetISO();
                rcptModel.BankTotals = receipt.GetBankTotals();
                rcptModel.Message = receipt.GetMessage();
                rcptModel.AuthCode = receipt.GetAuthCode();
                rcptModel.Complete = receipt.GetComplete();
                rcptModel.TransDate = receipt.GetTransDate();
                rcptModel.TransTime = receipt.GetTransTime();
                rcptModel.Ticket = receipt.GetTicket();
                rcptModel.TimedOut = receipt.GetTimedOut();
                rcptModel.IsVisaDebit = receipt.GetIsVisaDebit();
                //Console.WriteLine("StatusCode = " + receipt.GetStatusCode());
                //Console.WriteLine("StatusMessage = " + receipt.GetStatusMessage());
                return rcptModel;

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return null;
            }
        }
开发者ID:devnarayan,项目名称:MyRealtyWeb,代码行数:58,代码来源:MRWPurchase.cs

示例9: ConsumePurchase

        public bool ConsumePurchase(Purchase purchase)
        {
            if (purchase == null)
            {
                throw new ArgumentNullException("purchase");
            }

            return ConsumePurchase(purchase.PurchaseToken);
        }
开发者ID:shakor,项目名称:XamarinInAppBillingForCafeBazaar,代码行数:9,代码来源:InAppBillingHelper.cs

示例10: Create

 //
 // GET: /Purchase/Create
 public ActionResult Create()
 {
     Purchase p = new Purchase();
     p.TimeStamp = DateTime.Now;
     p.VAT = Convert.ToDecimal(System.Configuration.ConfigurationManager.AppSettings["DefaultVAT"]);
     ViewBag.ProviderID = new SelectList(db.Providers.OrderBy(pr => pr.Name), "ProviderID", "Name");
     ViewBag.PurchaseTypeID = new SelectList(db.PurchaseTypes.OrderBy(et=>et.Name), "PurchaseTypeID", "Name");
     return View(p);
 }
开发者ID:njmube,项目名称:CoffeeInvoice,代码行数:11,代码来源:PurchaseController.cs

示例11: CreateFromSku

        public static Purchase CreateFromSku(string sku, string developerPayload)
        {
            var p = new Purchase();
            p.Sku = sku;
            p.DeveloperPayload = developerPayload;
			#if UNITY_IOS
			AddIOSHack(p);
			#endif
            return p;
        }
开发者ID:kraftdream,项目名称:TimeKiller,代码行数:10,代码来源:Purchase.cs

示例12: Buy

 public string Buy(Purchase purchase)
 {
     purchase.Date = DateTime.Now;
     purchase.Subject = "Technics";
     // добавляем информацию о покупке в базу данных
     dbTechnics.Purchases.Add(purchase);
     // сохраняем в бд все изменения
     dbTechnics.SaveChanges();
     return "Спасибо за покупку!";
 }
开发者ID:MishaGubsky,项目名称:studies,代码行数:10,代码来源:TechnicsController.cs

示例13: Buy

 public string Buy(Purchase purchase)
 {
     purchase.Date = DateTime.Now;
     purchase.Subject = "Books";
     // добавляем информацию о покупке в базу данных
     Repository.dbBooks.Purchases.Add(purchase);
     // сохраняем в бд все изменения
     Repository.dbBooks.SaveChanges();
     return "Спасибо, за покупку!";
 }
开发者ID:MishaGubsky,项目名称:studies,代码行数:10,代码来源:BooksController.cs

示例14: Main

        public static void Main(string[] args)
        {
            string host = "esqa.moneris.com";
            string store_id = "store5";
            string api_token = "yesguy";
            string order_id = "Test_P_0333";
            string amount = "5.00";
            string pan = "4242424242424242";
            string expdate = "0812";
            string crypt = "7";
            //string status = "true";

            /* Status Check Example */
            //  HttpsPostRequest mpgReq =
            //    new HttpsPostRequest(host, store_id, api_token, status,
            //               new Purchase(order_id, amount, pan, expdate, crypt));

            Purchase purchase = new Purchase(order_id, amount, pan, expdate, crypt);

            //purchase.SetDynamicDescriptor("2134565");

            HttpsPostRequest mpgReq =
                  new HttpsPostRequest(host, store_id, api_token, purchase);

            try
            {
                Receipt receipt = mpgReq.GetReceipt();

                Console.WriteLine("CardType = " + receipt.GetCardType());
                Console.WriteLine("TransAmount = " + receipt.GetTransAmount());
                Console.WriteLine("TxnNumber = " + receipt.GetTxnNumber());
                Console.WriteLine("ReceiptId = " + receipt.GetReceiptId());
                Console.WriteLine("TransType = " + receipt.GetTransType());
                Console.WriteLine("ReferenceNum = " + receipt.GetReferenceNum());
                Console.WriteLine("ResponseCode = " + receipt.GetResponseCode());
                Console.WriteLine("ISO = " + receipt.GetISO());
                Console.WriteLine("BankTotals = " + receipt.GetBankTotals());
                Console.WriteLine("Message = " + receipt.GetMessage());
                Console.WriteLine("AuthCode = " + receipt.GetAuthCode());
                Console.WriteLine("Complete = " + receipt.GetComplete());
                Console.WriteLine("TransDate = " + receipt.GetTransDate());
                Console.WriteLine("TransTime = " + receipt.GetTransTime());
                Console.WriteLine("Ticket = " + receipt.GetTicket());
                Console.WriteLine("TimedOut = " + receipt.GetTimedOut());
                Console.WriteLine("IsVisaDebit = " + receipt.GetIsVisaDebit());
                //Console.WriteLine("StatusCode = " + receipt.GetStatusCode());
                //Console.WriteLine("StatusMessage = " + receipt.GetStatusMessage());

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
开发者ID:devnarayan,项目名称:MyRealtyWeb,代码行数:54,代码来源:TestPurchase.cs

示例15: SaleDetailsWindow

        public SaleDetailsWindow(Purchase purch)
        {
            InitializeComponent();

            lblHeader.Text = purch.User.Username;
            lblDate.Text = "Datum:\t" + purch.Date.ToString();
            lblCount.Text = "Anzahl:\t" + purch.Count.ToString();
            lblAmount.Text = "Summe:\t" + string.Format("{0:0.00 €}", purch.Amount);

            dgvArticles.ItemsSource = purch.Articles;
        }
开发者ID:fhoner,项目名称:Kasse,代码行数:11,代码来源:SaleDetailsWindow.xaml.cs


注:本文中的Purchase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。