56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using Weee.Models.Paramemter;
|
|||
|
|
|||
|
namespace Weee.DAL
|
|||
|
{
|
|||
|
public class NonYearlyParameterBuilder : ParameterBuilder
|
|||
|
{
|
|||
|
private NonYearlyParameterCategory _category { get; set; }
|
|||
|
private List<NonYearlyParameterType> _types { get; set; }
|
|||
|
private List<NonYearlyParameter> _parameters { get; set; }
|
|||
|
public NonYearlyParameterBuilder(Categories cate)
|
|||
|
{
|
|||
|
_category = new NonYearlyParameterCategory() { Category = cate };
|
|||
|
}
|
|||
|
|
|||
|
public NonYearlyParameterBuilder BuildTypes(List<string> TwNames, List<string> CNNames, List<string> ENNames)
|
|||
|
{
|
|||
|
if (_types == null) _types = new List<NonYearlyParameterType>();
|
|||
|
|
|||
|
var Names = CunstructMultiNames(TwNames, CNNames, ENNames);
|
|||
|
|
|||
|
foreach (var Name in Names)
|
|||
|
{
|
|||
|
var newtype = new NonYearlyParameterType()
|
|||
|
{
|
|||
|
Category = _category,
|
|||
|
DisplayNameTW = Name.TWName,
|
|||
|
DisplayNameCN = Name.CNName,
|
|||
|
DisplayNameEN = Name.ENName
|
|||
|
};
|
|||
|
_types.Add(newtype);
|
|||
|
}
|
|||
|
_category.Types = _types;
|
|||
|
return this;
|
|||
|
}
|
|||
|
|
|||
|
public NonYearlyParameterBuilder BuildParameters(List<decimal> ToBeBuilded)
|
|||
|
{
|
|||
|
if (_types == null || _types.Count() == 0) throw new Exception("The Type Is Empty , please build Type first");
|
|||
|
if (_parameters == null) _parameters = new List<NonYearlyParameter>();
|
|||
|
for (int i = 0; i < _types.Count; i++)
|
|||
|
{
|
|||
|
var created= new NonYearlyParameter() { Value = i<ToBeBuilded.Count?ToBeBuilded[i]:0m, Type = _types[i] };
|
|||
|
_types[i].Parameters.Add(created);
|
|||
|
}
|
|||
|
return this;
|
|||
|
}
|
|||
|
|
|||
|
public NonYearlyParameterCategory GetResults()
|
|||
|
{
|
|||
|
return _category;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|