|
@@ -1095,81 +1095,92 @@ namespace UnivateProperties_API.Repository.Timeshare
|
1095
|
1095
|
#endregion
|
1096
|
1096
|
|
1097
|
1097
|
var week = new TimeshareWeek();
|
1098
|
|
- foreach (string prop in week.GetAllProperties())
|
1099
|
|
- {
|
1100
|
|
- if (prop != "Item" && prop != "Display")
|
1101
|
|
- week[prop] = sellItem[prop];
|
1102
|
|
- }
|
1103
|
|
- week.Region = null;
|
1104
|
|
- week.RegionId = sellItem.Region.Id;
|
1105
|
|
-
|
1106
|
|
- //if agentWeek then set week owner equal to agentWeek.id else
|
1107
|
|
- if (agentWeek != null)
|
1108
|
|
- {
|
1109
|
|
- week.OwnerId = agentWeek.Id;
|
1110
|
|
- }
|
1111
|
|
- else
|
1112
|
|
- {
|
1113
|
|
- week.OwnerId = owner.Id;
|
1114
|
|
- }
|
1115
|
|
-
|
1116
|
|
- if (week.Mandate)
|
1117
|
|
- week.DateMandated = DateTime.Now;
|
1118
|
|
-
|
1119
|
|
- TemplateRepository templateRepository = new TemplateRepository(_dbContext);
|
1120
|
|
- MailRepository mailRepository = new MailRepository(_dbContext);
|
1121
|
|
- var template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekLoaded-Owner");
|
1122
|
1098
|
|
1123
|
1099
|
try
|
1124
|
1100
|
{
|
|
1101
|
+ foreach (string prop in week.GetAllProperties())
|
|
1102
|
+ {
|
|
1103
|
+ if (prop != "Item" && prop != "Display")
|
|
1104
|
+ week[prop] = sellItem[prop];
|
|
1105
|
+ }
|
|
1106
|
+ week.Region = null;
|
|
1107
|
+ week.RegionId = sellItem.Region.Id;
|
|
1108
|
+
|
|
1109
|
+ //if agentWeek then set week owner equal to agentWeek.id else
|
1125
|
1110
|
if (agentWeek != null)
|
1126
|
1111
|
{
|
1127
|
|
- template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekLoaded-Agent");
|
1128
|
|
- if (template != null)
|
1129
|
|
- {
|
1130
|
|
- mailRepository.WeekLoadedAgent(sellItem);
|
1131
|
|
- //templateRepository.SendEmailTemplateWeek(template, agent, sellItem);
|
1132
|
|
- }
|
|
1112
|
+ week.OwnerId = agentWeek.Id;
|
1133
|
1113
|
}
|
1134
|
1114
|
else
|
1135
|
1115
|
{
|
1136
|
|
- if (template != null)
|
|
1116
|
+ week.OwnerId = owner.Id;
|
|
1117
|
+ }
|
|
1118
|
+
|
|
1119
|
+ if (week.Mandate)
|
|
1120
|
+ week.DateMandated = DateTime.Now;
|
|
1121
|
+
|
|
1122
|
+ TemplateRepository templateRepository = new TemplateRepository(_dbContext);
|
|
1123
|
+ MailRepository mailRepository = new MailRepository(_dbContext);
|
|
1124
|
+ var template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekLoaded-Owner");
|
|
1125
|
+
|
|
1126
|
+ try
|
|
1127
|
+ {
|
|
1128
|
+ if (agentWeek != null)
|
1137
|
1129
|
{
|
1138
|
|
- mailRepository.WeekLoadedOwner(sellItem);
|
1139
|
|
- //templateRepository.SendEmailTemplateWeek(template, owner, sellItem);
|
|
1130
|
+ template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekLoaded-Agent");
|
|
1131
|
+ if (template != null)
|
|
1132
|
+ {
|
|
1133
|
+ mailRepository.WeekLoadedAgent(sellItem);
|
|
1134
|
+ //templateRepository.SendEmailTemplateWeek(template, agent, sellItem);
|
|
1135
|
+ }
|
1140
|
1136
|
}
|
1141
|
|
- /*template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekLoaded-UV");
|
1142
|
|
- if (template != null)
|
|
1137
|
+ else
|
1143
|
1138
|
{
|
1144
|
|
- templateRepository.SendEmailTemplate(template, sellItem.Owner, new List<BaseEntity>() { sellItem, sellItem.Owner });
|
1145
|
|
- }*/
|
|
1139
|
+ if (template != null)
|
|
1140
|
+ {
|
|
1141
|
+ mailRepository.WeekLoadedOwner(sellItem);
|
|
1142
|
+ //templateRepository.SendEmailTemplateWeek(template, owner, sellItem);
|
|
1143
|
+ }
|
|
1144
|
+ /*template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekLoaded-UV");
|
|
1145
|
+ if (template != null)
|
|
1146
|
+ {
|
|
1147
|
+ templateRepository.SendEmailTemplate(template, sellItem.Owner, new List<BaseEntity>() { sellItem, sellItem.Owner });
|
|
1148
|
+ }*/
|
1146
|
1149
|
|
|
1150
|
+ }
|
|
1151
|
+ }
|
|
1152
|
+ catch (Exception ex)
|
|
1153
|
+ {
|
|
1154
|
+ MailModel mm = new MailModel();
|
|
1155
|
+ mm.ComType = "WeekLoad";
|
|
1156
|
+ mm.Error = ex.ToString();
|
|
1157
|
+ _dbContext.CommunicationLog.Add(mm);
|
1147
|
1158
|
}
|
1148
|
|
- }
|
1149
|
|
- catch (Exception ex)
|
1150
|
|
- {
|
1151
|
|
- throw (ex);
|
1152
|
|
- }
|
1153
|
1159
|
|
1154
|
|
- if (sellItem.StatusId == 0)
|
1155
|
|
- {
|
1156
|
|
- var statuses = _dbContext.Status.ToList();
|
1157
|
|
- foreach (var statusItem in statuses)
|
|
1160
|
+ if (sellItem.StatusId == 0)
|
1158
|
1161
|
{
|
1159
|
|
- if (statusItem.Code == "AP")
|
|
1162
|
+ var statuses = _dbContext.Status.ToList();
|
|
1163
|
+ foreach (var statusItem in statuses)
|
1160
|
1164
|
{
|
1161
|
|
- week.StatusId = statusItem.Id;
|
|
1165
|
+ if (statusItem.Code == "AP")
|
|
1166
|
+ {
|
|
1167
|
+ week.StatusId = statusItem.Id;
|
|
1168
|
+ }
|
1162
|
1169
|
}
|
1163
|
1170
|
}
|
1164
|
|
- }
|
1165
|
1171
|
|
1166
|
|
- _dbContext.Add(week);
|
1167
|
|
- Save();
|
1168
|
|
- if (sellItem.CustomOwner)
|
1169
|
|
- {
|
1170
|
|
- indiv.WeekId = week.Id;
|
1171
|
|
- _dbContext.NonRegIndividuals.Update(indiv);
|
|
1172
|
+ _dbContext.Add(week);
|
1172
|
1173
|
Save();
|
|
1174
|
+ if (sellItem.CustomOwner)
|
|
1175
|
+ {
|
|
1176
|
+ indiv.WeekId = week.Id;
|
|
1177
|
+ _dbContext.NonRegIndividuals.Update(indiv);
|
|
1178
|
+ Save();
|
|
1179
|
+ }
|
|
1180
|
+ }
|
|
1181
|
+ catch (Exception ex)
|
|
1182
|
+ {
|
|
1183
|
+ throw (ex);
|
1173
|
1184
|
}
|
1174
|
1185
|
return week.Id;
|
1175
|
1186
|
}
|