public async Task <IActionResult> PutPurchaseitem([FromRoute] int id, [FromBody] Purchaseitem purchaseitem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != purchaseitem.Id) { return(BadRequest()); } _context.Entry(purchaseitem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PurchaseitemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void SaveTransaction(TransactionDto transaction, string code) { var purchase = new Purchase { UserId = transaction.UserId, PurchaseDate = DateTime.Now, PaymentMethod = 1, PaymentStatus = 0, PaymentStatusMessage = "NOT PAYED", PaymentToken = code, }; _context.Purchase.Add(purchase); _context.SaveChanges(); foreach (var item in transaction.Itens) { var purchaseItem = new Purchaseitem { GameId = item.GameId, Price = item.ItemAmount, PurchaseId = purchase.Id }; _context.Purchaseitem.Add(purchaseItem); } _context.SaveChanges(); }
public SuccessfulReciep(Purchaseitem products1) { InitializeComponent(); FlowDirectionPage(); this.products1 = products1; Totallbl.Text = products1.total_price; Salestk.IsVisible = false; Purchasestk.IsVisible = true; }
public async Task <IActionResult> PostPurchaseitem([FromBody] Purchaseitem purchaseitem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Purchaseitem.Add(purchaseitem); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPurchaseitem", new { id = purchaseitem.Id }, purchaseitem)); }
private async void Nextbtn_Clicked(object sender, EventArgs e) { try { ActiveIn.IsRunning = true; if (CrossConnectivity.Current.IsConnected) { using (var client = new HttpClient()) { //ObservableCollection<sub> subs = new ObservableCollection<sub>(); //foreach (var item2 in saleproducts) //{ // subs.Add(new sub // { // id = item2.id, // quantity = item2.quantity // }); //} foreach (var item in purchaseProducts) { Products productss = new Products { expiration_date = item.expiration_date.ToString(), id = item.id, purchase_price = item.purchase_price, quantity = item.quantity, sale_price = item.sale_price, total_price = item.total_price //payment_type = paymentid }; purchasero.Add(productss); } Purchaseitem products = new Purchaseitem { discount = Disclbl.Text, products = purchasero, total_price = totallbl.Text, supplier_id = supplier_id != null? supplier_id:"0", user_id = 3, //payment_type = paymentid }; var content = new MultipartFormDataContent(); //var jsoncategoryArray = JsonConvert.SerializeObject(products); //var values = new Dictionary<string, string> //{ // {"purchasing_Order",jsoncategoryArray } //}; //var req = new HttpRequestMessage(HttpMethod.Post, // "https://ittezanmobilepos.com/api/make_purchasing_Order") //{ Content = new FormUrlEncodedContent(values) }; //var response = await client.SendAsync(req); var js = JsonConvert.SerializeObject(products); content.Add(new StringContent(js, Encoding.UTF8, "text/json"), "purchasing_Order"); var response = await client.PostAsync("https://ittezanmobilepos.com/api/make_purchasing_Order", content); if (response.IsSuccessStatusCode) { var serverResponse = response.Content.ReadAsStringAsync().Result.ToString(); ActiveIn.IsRunning = false; var json = JsonConvert.DeserializeObject <SaleObject>(serverResponse); App.Current.MainPage = new SuccessfulReciep(products); } else { ActiveIn.IsRunning = false; await DisplayAlert(AppResources.Alert, AppResources.ConnectionNotAvailable, AppResources.Ok); } } } } catch (ValidationApiException validationException) { ActiveIn.IsRunning = false; await DisplayAlert(AppResources.Alert, AppResources.ConnectionNotAvailable, AppResources.Ok); // handle validation here by using validationException.Content, // which is type of ProblemDetails according to RFC 7807 } catch (ApiException exception) { ActiveIn.IsRunning = false; await DisplayAlert(AppResources.Alert, AppResources.ConnectionNotAvailable, AppResources.Ok); // other exception handling } }