public async Task <Model.Receipt> AddReceipt(int userId, int sourceId, Model.ReceiptType receiptType) { var receipt = new Model.Receipt() { ReceiptDate = System.DateTime.Now, ReceiptType = receiptType, UserId = userId, }; switch (receiptType) { case Model.ReceiptType.ExtraRecommendation: receipt.RecommendationId = sourceId; receipt.PaymentAmount = 1.5; break; case Model.ReceiptType.OneTimeRecommendation: receipt.RecommendationId = sourceId; receipt.PaymentAmount = 3; break; case Model.ReceiptType.Membership: receipt.MembershipId = sourceId; receipt.PaymentAmount = 5; break; } _context.Receipts.Attach(receipt); await _context.Receipts.AddAsync(receipt); await _context.SaveChangesAsync(); return(receipt); }
// this methods adds test data for the vehicle list public void loadData() { ReceiptList = new List <Model.Receipt>(); Model.Receipt r1 = new Model.Receipt { Total = 150, Tax = 15, ABN = "025478669785", Date = "20/08/20", Merchant = "Bunnings" }; Model.Receipt r2 = new Model.Receipt { Total = 200, Tax = 20, ABN = "025478779785", Date = "17/08/20", Merchant = "Mitre 10" }; Model.Receipt r3 = new Model.Receipt { Total = 70, Tax = 7, ABN = "025478669785", Date = "18/08/20", Merchant = "OTR" }; ReceiptList.Add(r1); ReceiptList.Add(r2); ReceiptList.Add(r3); }
private async void scanReceiptBtn_Clicked(object sender, EventArgs e) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await DisplayAlert("No Camera", ":( No camera available.", "OK"); return; } var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = "Sample", Name = "test.jpg", SaveToAlbum = true, DefaultCamera = Plugin.Media.Abstractions.CameraDevice.Front }); if (file == null) { return; } //await DisplayAlert("File Location", file.Path, "OK"); Model.Receipt receipt = new Model.Receipt(); receipt.receiptImg = new Image(); receipt.receiptImg.Source = ImageSource.FromStream(() => { var stream = file.GetStream(); return(stream); }); receipt.Total = 330; // Creating a new instance of Receipt details page. // Assigning the receipt object with the receipt image // to the page's bindinding context. // Finally we call the PushAsync method and we pass the // page we just created as a parameter. var receiptDetailsPage = new ReceiptDetails(); receiptDetailsPage.BindingContext = receipt; await Navigation.PushAsync(receiptDetailsPage); }