SubscriptionPriceModel.cs
4.06 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AIAHTML5.ADMIN.API.Entity;
namespace AIAHTML5.ADMIN.API.Models
{
public class SubscriptionPriceModel
{
public int Id { get; set; }
public string Title { get; set; }
public decimal Price { get; set; }
public int Duration { get; set; }
public int EditionId { get; set; }
public bool IsActive { get; set; }
public static List<SubscriptionPriceModel> GetSubscriptionPrices(AIADatabaseV5Entities dbContext, int editionId, int duration)
{
List<SubscriptionPriceModel> SubscriptionPriceList = new List<SubscriptionPriceModel>();
SubscriptionPriceModel SubscriptionPriceObj = new SubscriptionPriceModel();
try
{
var result = dbContext.Usp_GetSubscriptionPlans((byte?)editionId, (byte?)duration).ToList();
if (result.Count > 0)
{
foreach (var item in result)
{
SubscriptionPriceObj = new SubscriptionPriceModel();
SubscriptionPriceObj.Id = item.Id;
SubscriptionPriceObj.Title = item.title;
SubscriptionPriceObj.Price = item.price.Value;
SubscriptionPriceObj.Duration = item.Duration;
SubscriptionPriceObj.EditionId = item.Id;
SubscriptionPriceObj.IsActive = true ;
SubscriptionPriceList.Add(SubscriptionPriceObj);
}
}
}
catch (Exception ex) { }
return SubscriptionPriceList;
}
public static bool InsertSubscriptionPrice(AIADatabaseV5Entities dbContext, SubscriptionPriceModel subscriptionPriceModel)
{
var spStatus = new System.Data.Objects.ObjectParameter("Status", 0);
try
{
dbContext.Usp_InsertSubscriptionPlan((byte?)subscriptionPriceModel.Id, subscriptionPriceModel.Title, (decimal?)subscriptionPriceModel.Price,
(byte?)subscriptionPriceModel.Duration, (byte?)subscriptionPriceModel.EditionId, subscriptionPriceModel.IsActive, spStatus);
if (spStatus.Value.ToString() == "1")
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
return false;
}
}
public static bool UpdateSubscriptionPrice(AIADatabaseV5Entities dbContext, SubscriptionPriceModel subscriptionPriceModel)
{
var spStatus = new System.Data.Objects.ObjectParameter("Status", 0);
try
{
dbContext.Usp_UpdateSubscriptionPlan((byte?)subscriptionPriceModel.Id, subscriptionPriceModel.Title, subscriptionPriceModel.Price,
(byte?)subscriptionPriceModel.Duration, (byte?)subscriptionPriceModel.EditionId, subscriptionPriceModel.IsActive, spStatus);
if (spStatus.Value.ToString() == "1")
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
return false;
}
}
public static bool DeleteSubscriptionPrice(AIADatabaseV5Entities dbContext, int subscriptionPriceId)
{
var spStatus = new System.Data.Objects.ObjectParameter("Status", 0);
try
{
dbContext.Usp_DeleteSubscriptionPlan((byte?)subscriptionPriceId, spStatus);
if (spStatus.Value.ToString() == "1")
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
return false;
}
}
}
}