From 00232a4b033042212dec65d546e98d1b0ad6432d Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 30 Aug 2016 23:04:25 +0200 Subject: [PATCH] refactoring --- Yavsc/Model/Market/IUnit.cs | 7 +++++ Yavsc/Model/Market/Money.cs | 37 +++++++++++++++++++++++ Yavsc/Model/Market/Service.cs | 55 ++--------------------------------- 3 files changed, 46 insertions(+), 53 deletions(-) create mode 100644 Yavsc/Model/Market/IUnit.cs create mode 100644 Yavsc/Model/Market/Money.cs diff --git a/Yavsc/Model/Market/IUnit.cs b/Yavsc/Model/Market/IUnit.cs new file mode 100644 index 00000000..fe95b18e --- /dev/null +++ b/Yavsc/Model/Market/IUnit.cs @@ -0,0 +1,7 @@ +namespace Yavsc.Models.Market { + public interface IUnit { + string Name { get; } + bool CanConvertFrom(IUnit other); + VType ConvertFrom (IUnit other, VType orgValue) ; + } +} \ No newline at end of file diff --git a/Yavsc/Model/Market/Money.cs b/Yavsc/Model/Market/Money.cs new file mode 100644 index 00000000..7bb4b175 --- /dev/null +++ b/Yavsc/Model/Market/Money.cs @@ -0,0 +1,37 @@ +using System; + +namespace Yavsc.Models.Market { + public class Money : IUnit + { + public Money(string name, decimal euroExchangeRate) + { + Name = name; + EuroExchangeRate = euroExchangeRate; + } + + public string Name + { + get; private set ; + } + + public decimal EuroExchangeRate + { + get; private set ; + } + public bool CanConvertFrom(IUnit other) + { + if (other is Money) + return true; + return false; + } + + public decimal ConvertFrom(IUnit other, decimal orgValue) + { + if (other is Money) { + var om = other as Money; + return orgValue * om.EuroExchangeRate / EuroExchangeRate; + } + throw new NotImplementedException(); + } + } + } \ No newline at end of file diff --git a/Yavsc/Model/Market/Service.cs b/Yavsc/Model/Market/Service.cs index b0f2fdd7..16db3d89 100644 --- a/Yavsc/Model/Market/Service.cs +++ b/Yavsc/Model/Market/Service.cs @@ -1,66 +1,15 @@ namespace Yavsc.Models.Market { - using System; + using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; - public enum BillingMode {  - Unitary, - SetPrice, - ByExecutionTime - } - - public interface IUnit { - string Name { get; } - bool CanConvertFrom(IUnit other); - VType ConvertFrom (IUnit other, VType orgValue) ; - } - public class Money : IUnit - { - public Money(string name, decimal euroExchangeRate) - { - Name = name; - EuroExchangeRate = euroExchangeRate; - } - - public string Name - { - get; private set ; - } - - public decimal EuroExchangeRate - { - get; private set ; - } - public bool CanConvertFrom(IUnit other) - { - if (other is Money) - return true; - return false; - } - - public decimal ConvertFrom(IUnit other, decimal orgValue) - { - if (other is Money) { - var om = other as Money; - return orgValue * om.EuroExchangeRate / EuroExchangeRate; - } - throw new NotImplementedException(); - } - } - public partial class Service : BaseProduct { public string ContextId { get; set; } [ForeignKey("ContextId")] public virtual Activity Context { get; set; } - public BillingMode? Billing { get; set; } - // TODO public ServiceSpecification Specification { get; set; } - /// - /// In euro - /// - /// - public decimal? Pricing { get; set; } + public List Billing { get; set; } }