Skip to content

Commit

Permalink
#4 Fixed Naming Conventions Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
charansingh83sh committed Sep 15, 2020
1 parent c74d080 commit d96f28a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 57 deletions.
18 changes: 9 additions & 9 deletions CustomerService/Classes/ResultsWithEvents.cs
Expand Up @@ -9,25 +9,25 @@ namespace CustomerService.Classes
{
public class ResultsWithEvents
{
public Customer customer;
public List<IDomainEvent> events;
public Customer Customer { get; set; }
public List<IDomainEvent> Events { get; set; }

public ResultsWithEvents()
{
}

public ResultsWithEvents(Customer _customer, List<IDomainEvent> _events)
public ResultsWithEvents(Customer customer, List<IDomainEvent> events)
{
customer = _customer;
events = _events;
Customer = customer;
Events = events;
}

public ResultsWithEvents(Customer _customer, IDomainEvent _event)
public ResultsWithEvents(Customer customer, IDomainEvent domainEvent)
{
customer = _customer;
Customer = customer;
List<IDomainEvent> eventList = new List<IDomainEvent>();
eventList.Add(_event);
events = eventList;
eventList.Add(domainEvent);
Events = eventList;
}
}
}
2 changes: 1 addition & 1 deletion CustomerService/Controllers/CustomerController.cs
Expand Up @@ -29,7 +29,7 @@ public IActionResult CreateCustomer([FromBody] CreateCustomerRequest request)
{
CustomerDataService customerService = new CustomerDataService(customerRepository, domainEventPublisher);
Customer customer = customerService.CreateCustomer(request.Name, request.CreditLimit);
CreateCustomerResponse createCustomerResponse = new CreateCustomerResponse(customer.id);
CreateCustomerResponse createCustomerResponse = new CreateCustomerResponse(customer.Id);
return Ok(createCustomerResponse);
}
}
Expand Down
19 changes: 11 additions & 8 deletions CustomerService/Models/Customer.cs
Expand Up @@ -12,19 +12,22 @@ namespace CustomerService.Models
[Table("Customer")]
public class Customer
{
public long id { get; set; }
public string name { get; set; }
[Column("id")]
public long Id { get; set; }
[Column("name")]
public string Name { get; set; }
[NotMapped]
public Money creditlimit { get; set; }
public DateTime creationtime { get; set; }
public Money CreditLimit { get; set; }
[Column("creationtime")]
public DateTime CreationTime { get; set; }
public Customer()
{
}
public Customer(String _name, Money _creditLimit)
public Customer(string name, Money creditLimit)
{
name = _name;
creditlimit = _creditLimit;
creationtime = System.DateTime.Now;
Name = name;
CreditLimit = creditLimit;
CreationTime = System.DateTime.Now;
}

}
Expand Down
6 changes: 3 additions & 3 deletions CustomerService/Service/CustomerDataService.cs
Expand Up @@ -27,16 +27,16 @@ public Customer CreateCustomer(String name, Money creditLimit)
using (var scope = new TransactionScope())
{
ResultsWithEvents customerWithEvents = Create(name, creditLimit);
customer = customerRepository.InsertCustomer(customerWithEvents.customer);
domainEventPublisher.Publish(customer.id.ToString(), customer.id, customerWithEvents.events);
customer = customerRepository.InsertCustomer(customerWithEvents.Customer);
domainEventPublisher.Publish(customer.Id.ToString(), customer.Id, customerWithEvents.Events);
scope.Complete();
return customer;
}
}
public static ResultsWithEvents Create(String name, Money creditLimit)
{
Customer customer = new Customer(name, creditLimit);
var customerCreatedEvent = new CustomerCreatedEvent(customer.name, customer.creditlimit);
var customerCreatedEvent = new CustomerCreatedEvent(customer.Name, customer.CreditLimit);
List<IDomainEvent> eventList = new List<IDomainEvent>();
eventList.Add(customerCreatedEvent);
return new ResultsWithEvents(customer, eventList);
Expand Down
2 changes: 1 addition & 1 deletion EndToEndTests/CustomersAndOrdersEndToEndTest.cs
Expand Up @@ -34,7 +34,7 @@ public async Task CustomerShouldbeCreated()
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
string jsonString = await response.Content.ReadAsStringAsync();
var customerResponse = JsonSerializer.Deserialize<CreateCustomerResponse>(jsonString);
Assert.IsNotNull(customerResponse.customerId);
Assert.IsNotNull(customerResponse.CustomerId);
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions ServiceCommon/Classes/CustomerCreatedEvent.cs
Expand Up @@ -7,36 +7,36 @@ namespace ServiceCommon.Classes
{
public class CustomerCreatedEvent : ICustomerEvent
{
public String name { get; set; }
private Money creditLimit { get; set; }
public String Name { get; set; }
private Money CreditLimit { get; set; }
public CustomerCreatedEvent()
{
}

public CustomerCreatedEvent(String _name, Money _creditLimit)
public CustomerCreatedEvent(String name, Money creditLimit)
{
name = name;
creditLimit = creditLimit;
Name = name;
CreditLimit = creditLimit;
}

public String GetName()
{
return name;
return Name;
}

public void SetName(String name)
{
this.name = name;
Name = name;
}

public Money GetCreditLimit()
{
return creditLimit;
return CreditLimit;
}

public void SetCreditLimit(Money _creditLimit)
public void SetCreditLimit(Money creditLimit)
{
creditLimit = _creditLimit;
CreditLimit = creditLimit;
}
}
}
33 changes: 11 additions & 22 deletions ServiceCommon/Classes/Money.cs
Expand Up @@ -8,48 +8,37 @@ namespace ServiceCommon.Classes
public class Money
{
public static Money ZERO = new Money(0);
public decimal amount { get; set; }
public decimal Amount { get; set; }

public Money()
{
}

public Money(int i)
{
amount = Convert.ToDecimal(i);
Amount = Convert.ToDecimal(i);
}
public Money(String s)
{
amount = Convert.ToDecimal(s);
Amount = Convert.ToDecimal(s);
}

public Money(decimal _amount)
public Money(decimal amount)
{
amount = _amount;
Amount = amount;
}

public decimal getAmount()
{
return amount;
}

public void setAmount(decimal _amount)
{
this.amount = _amount;
}

public bool isGreaterThanOrEqual(Money other)
public bool IsGreaterThanOrEqual(Money other)
{
return amount >= other.amount;
return Amount >= other.Amount;
}

public Money add(Money other)
public Money Add(Money other)
{
return new Money(amount + (other.amount));
return new Money(Amount + (other.Amount));
}
public Money subtract(Money other)
public Money Subtract(Money other)
{
return new Money(amount - (other.amount));
return new Money(Amount - (other.Amount));
}
}
}
6 changes: 3 additions & 3 deletions ServiceCommon/WebAPI/CreateCustomerResponse.cs
Expand Up @@ -7,15 +7,15 @@ namespace ServiceCommon.Common
{
public class CreateCustomerResponse
{
public long customerId { get; set; }
public long CustomerId { get; set; }

public CreateCustomerResponse()
{
}

public CreateCustomerResponse(long _customerId)
public CreateCustomerResponse(long customerId)
{
customerId = _customerId;
CustomerId = customerId;
}
}
}

0 comments on commit d96f28a

Please sign in to comment.