Question
Customer should be able to redeem points only when the unredeemed reward points are above 100 Customer's balance should be increased when the rewards points
Please make the code using these getters and setters:
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks;
namespace AmigoWalletWebServices.Models { public class UserTransaction { public long UserTransactionId { get; set; } public string EmailId { get; set; } public decimal Amount { get; set; } public DateTime TransactionDateTime { get; set; } public byte PaymentTypeId { get; set; } public string Remarks { get; set; } public string Info { get; set; } public byte StatusId { get; set; } public short? PointsEarned { get; set; } public bool IsRedeemed { get; set; }
public decimal balance{ get; set; } } }
These are bits and pieces of the code done so far.
//Code for redeem points
using System.IO; using System;
namespace ewallet_code_david_snow { public class RedeemPoints { public static void Main() { int rp = 0; //redeem points double bal = 0; //balance Console.WriteLine(\"Enter Redeem points:\"); //Get the input from user for Redeem points rp = Convert.ToInt32(Console.ReadLine()); //convert the value to int Console.WriteLine(\"Enter the current balance:\"); bal = Convert.ToDouble(Console.ReadLine()); //convert the value to double if (rp > 100) { //only redeem points when > 100 Console.WriteLine(\"Customer is able to redeem points\"); rp = rp * 10 / 100; //as only 10 % of redeemed points should get credited bal += rp; //and then adding that to the existing balance amount Console.Write(\"Redeem Points amount\"); Console.Write(\" \" + bal); } else { Console.Write(\"Customer does not have enough points\"); Console.WriteLine(\"Error: Cannot update\"); }
/*Below scenarios are not specifically required Moreover partial redemption is not supported. In that case, we need to check only when rp > 100 as like above calculation if(rp >= 110){ Console.Write(bal *( 1.01)); } else if(rp >= 120){ Console.Write(bal * 1.03); } else if (rp >= 130){ Console.Write(bal * 1.05); } */ } } }
//code for displaying transaction log
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.ComponentModel.DataAnnotations;
namespace BindingDataFromDatabase.Model{ [key] public class AmigoWalletClass{ public DateTime transactionDate { get; set; } public string transactionInfo { get; set; } public string transactionType { get; set; } public double amount { get; set; } public bool status { get; set; } }
These are all the codes in C#, However for the transaction log I will provide the code with the DB and HTML that I've done so far to help with the C# part.
//Index.cshtml.cs using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Mircrosft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; using BindingDataFromDatabase.Model;
namespace BindingDataFromDatabase.Pages { public class IndexModel : PageModel { private readonly ConnectionDBClass _db; public IndexModel (ConnectionDBClass db) { _db = db; } public IEnumerable getrecords {get; set;} public async Task onGet(){ getrecords = await _db.empjsondata.ToListAsync();
//Index.cshtml @Page @model IndexModel @{ ViewData[\"Title\"] = \"Home page\"; }
asp.net Core 3.0 Tutorials h2> Display Records From Database SQL Server
@foreach(var item in model.getrecords) { }
Transaction Date | Transaction Info | Transaction Type | Amount | Status |
---|---|---|---|---|
@item.transactionDate | @item.transactionInfo | @item.transactionType | @item.amount | @item.status |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started