-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrdersModel.cs
46 lines (37 loc) · 1.08 KB
/
OrdersModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StrataTest
{
public class Order
{
public string Id;
public string Customer;
public DateTime Date;
public string Address;
public double Amount;
}
internal class OrderModel
{
// return new order id
public string Add(string sCustomer, string sAddress, double dAmount)
{
string sId = Guid.NewGuid().ToString();
Order order = new Order() { Id = sId, Customer = sCustomer, Address = sAddress, Amount = dAmount, Date = DateTime.Now };
Repository.Orders.Add(order);
return sId;
}
public Order Get(string sId)
{
return
(from o in Repository.Orders
where o.Id == sId
select o).SingleOrDefault();
}
public bool Delete(string sID)
{
return Repository.Orders.RemoveAll(o => o.Id == sID) != 0;
}
}
}