业务逻辑ASP.NET MV

时间:2016-04-10 17:16:03

标签: c# asp.net-mvc mongodb

我需要一些帮助。我有一个名为JumlahTransaksi的模型类,我想用PersenTopUp计算public class Transaksi { public Transaksi() { Members = new Member(); Groups = new Group(); Profits = new Profit(); Level = new Level(); JenisTransaksi = new JenisTransaksi(); } [BsonId] public string Id { get; set; } public Member Members { get; set; } public Group Groups { get; set; } public int NoTransaksi { get; set; } [BsonRepresentation(MongoDB.Bson.BsonType.Double)] public double BatasTransaksi { get; set; } [BsonRepresentation(BsonType.String)] public JenisTransaksi JenisTransaksi { get; set; } [BsonRepresentation(BsonType.Double)] public double PersenTopUp { get; set; } [BsonRepresentation(BsonType.Double)] public double PersenRef { get; set; } [BsonRepresentation(BsonType.Double)] public double JumlahTransaksi { get; set; } [BsonDateTimeOptions(Kind = DateTimeKind.Local, DateOnly = true)] public DateTime TanggalTransaksi { get; set; } [BsonDateTimeOptions(Kind = DateTimeKind.Local, DateOnly = true)] public DateTime TglJatuhTempo { get { return (this.TanggalTransaksi.AddYears(1)); } } // Setiap member memiliki list profit public Profit Profits { get; set; } [BsonRepresentation(BsonType.String)] public Level Level { get; set; } [BsonRepresentation(BsonType.String)] public StatusTransaksi StatusTransaksi; [BsonRepresentation(MongoDB.Bson.BsonType.String)] public string Keterangan { get; set; } [BsonDateTimeOptions(Kind = DateTimeKind.Local, DateOnly = true)] public DateTime TerakhirDiubah { get; set; } } ,我应该在哪里设置函数来计算它?在模型或控制器中?

isset($_POST)

1 个答案:

答案 0 :(得分:0)

您可以在模型中定义一个用PersenTopUp计算JumlahTransaksi的函数。

public double MakeSum()
{
   return PersenTopUp + JumlahTransaksi;
}