Congratulations - C# Corner Q4, 2022 MVPs Announced
Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Gcobani Mkontwana
1k
1.5k
255.7k
How to implement coin jar in c# using Rest API?
Oct 14 2020 2:48 AM
Hi Team
I need some help with my requirement to implement coin jar in c# using rest api. My requirement are as below;
"coin jar only accept latest us coinage, must have volume of 42 fluids ounces"
"must have a counter to keep track of the total amount of money collected"
"reset the count back to $0.00."
My logic so far is as follows in c# using rest api
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Net;
using
System.Net.Http;
using
System.Web.Http;
namespace
CoinJarAPI.Controllers
{
public
class
CoinJarController : ApiController
{
// GET: api/CoinJar
public
IEnumerable<
string
> Get()
{
return
new
string
[] {
"value1"
,
"value2"
};
}
// GET: api/CoinJar/5
public
string
Get(
int
id)
{
return
"value"
;
}
// POST: api/CoinJar
public
void
Post([FromBody]
string
value)
{
}
// PUT: api/CoinJar/5
public
void
Put(
int
id, [FromBody]
string
value)
{
}
// DELETE: api/CoinJar/5
public
void
Delete(
int
id)
{
}
}
}
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
CoinJarAPI.Interface
{
interface
ICoinJar
{
void
AddCoin(ICoin coin);
decimal
GetTotalAmount();
void
Reset();
}
public
interface
ICoin
{
decimal
Amount {
get
;
set
; }
decimal
Volume {
get
;
set
; }
}
}
using
CoinJarAPI.Interface;
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
namespace
CoinJarAPI.Repository
{
public
class
Repository : ICoinJar
{
public
void
AddCoin(ICoin coin)
{
throw
new
NotImplementedException();
}
public
decimal
GetTotalAmount()
{
throw
new
NotImplementedException();
}
public
void
Reset()
{
throw
new
NotImplementedException();
}
}
}
Reply
Answers (
6
)
how to convert asp file into asp.net
Can A CHATBOT developed in Visual Studio (ASP.Net) and be deployed in