Update Happiness Task
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
using Church.Net.DAL.EFCoreDBF;
|
||||
using Church.Net.Entity;
|
||||
using Church.Net.Utility;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using WebAPI.Logics.Core;
|
||||
using WebAPI.Logics.Interface;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace WebAPI.Logics
|
||||
{
|
||||
public class CellGroupLogic
|
||||
{
|
||||
private readonly IServiceScopeFactory serviceScopeFactory;
|
||||
private readonly ICrudDAL<CellGroupRoutineEvent> eventCrudDAL;
|
||||
private readonly ICombinedKeyCrudDAL<CellGroupRoutineEventAttendee> attendeeCrudDAL;
|
||||
private readonly ICrudDAL<FamilyMember> memberCrudDAL;
|
||||
|
||||
public CellGroupLogic(
|
||||
IServiceScopeFactory serviceScopeFactory,
|
||||
ICrudDAL<CellGroupRoutineEvent> eventCrudDAL,
|
||||
ICombinedKeyCrudDAL<CellGroupRoutineEventAttendee> attendeeCrudDAL,
|
||||
ICrudDAL<FamilyMember> memberCrudDAL
|
||||
)
|
||||
{
|
||||
this.serviceScopeFactory = serviceScopeFactory;
|
||||
this.eventCrudDAL = eventCrudDAL;
|
||||
this.attendeeCrudDAL = attendeeCrudDAL;
|
||||
this.memberCrudDAL = memberCrudDAL;
|
||||
}
|
||||
|
||||
public CellGroupRoutineEvent GetComingEvent()
|
||||
{
|
||||
var _event = eventCrudDAL.GetDbSet().Where(e => e.Time >= DateTime.UtcNow)
|
||||
.Include(e => e.Attendees).Include(e => e.Prayers).FirstOrDefault();
|
||||
if (_event == null)
|
||||
{
|
||||
_event = new CellGroupRoutineEvent()
|
||||
{
|
||||
Id = Format.Get33BaseGuid(),
|
||||
Time = DateTimeHelper.GetNextWeekday(DateTime.Today, DayOfWeek.Friday).AddHours(19).AddMinutes(30),
|
||||
Address = "1881 Forest Dr., Azusa, CA 91702",
|
||||
Attendees = new List<CellGroupRoutineEventAttendee>()
|
||||
};
|
||||
eventCrudDAL.Create(_event);
|
||||
}
|
||||
|
||||
return _event;
|
||||
}
|
||||
public CellGroupRoutineEvent GetLastEvent()
|
||||
{
|
||||
var _event = eventCrudDAL.GetDbSet().OrderByDescending(e=>e.Time)
|
||||
.Include(e => e.Attendees).Include(e => e.Prayers).FirstOrDefault();
|
||||
return _event;
|
||||
}
|
||||
|
||||
public string GetMemberFirstNameById(string memberId)
|
||||
{
|
||||
return memberCrudDAL.GetById(memberId)?.FirstName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,23 +30,37 @@ namespace WebAPI.Logics.Core
|
||||
return this.crudDAL.CheckExist(obj);
|
||||
}
|
||||
|
||||
public virtual void BeforeCreate(T entity)
|
||||
{
|
||||
}
|
||||
public virtual int Create(T entity)
|
||||
{
|
||||
return this.crudDAL.Create(entity);
|
||||
BeforeCreate(entity);
|
||||
return this.crudDAL.Create(entity) + CreateDone(entity);
|
||||
}
|
||||
|
||||
public virtual Task<int> CreateAsync(T entity)
|
||||
{
|
||||
BeforeCreate(entity);
|
||||
return this.crudDAL.CreateAsync(entity);
|
||||
}
|
||||
|
||||
public void CreateDone(T entity)
|
||||
public virtual int CreateDone(T entity)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int CreateOrUpdate(T entity, out string id)
|
||||
public virtual int CreateOrUpdate(T entity, out string id)
|
||||
{
|
||||
var result= this.crudDAL.CreateOrUpdate(entity);
|
||||
int result = 0;
|
||||
if (this.crudDAL.CheckExist(entity))
|
||||
{
|
||||
result = this.Update(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = this.Create(entity);
|
||||
}
|
||||
id = entity.Id;
|
||||
return result;
|
||||
}
|
||||
@@ -56,7 +70,7 @@ namespace WebAPI.Logics.Core
|
||||
// return this.crudDAL.CreateReturnId(entity);
|
||||
//}
|
||||
|
||||
public int Delete(T obj)
|
||||
public virtual int Delete(T obj)
|
||||
{
|
||||
return this.crudDAL.Delete(obj);
|
||||
}
|
||||
@@ -70,7 +84,7 @@ namespace WebAPI.Logics.Core
|
||||
return this.crudDAL.First(filter);
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetAll(Func<T, bool> filter = null)
|
||||
public virtual IEnumerable<T> GetAll(Func<T, bool> filter = null)
|
||||
{
|
||||
return this.crudDAL.GetAll(filter);
|
||||
}
|
||||
@@ -85,18 +99,39 @@ namespace WebAPI.Logics.Core
|
||||
return this.crudDAL.GetById(Id);
|
||||
}
|
||||
|
||||
public int Update(T entity)
|
||||
public virtual void BeforeUpdate(T entity)
|
||||
{
|
||||
return this.crudDAL.Update(entity);
|
||||
}
|
||||
|
||||
public void UpdateDone(T entity)
|
||||
public virtual int Update(T entity)
|
||||
{
|
||||
BeforeUpdate(entity);
|
||||
return this.crudDAL.Update(entity)+ UpdateDone(entity);
|
||||
}
|
||||
|
||||
public virtual int UpdateDone(T entity)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int UpdateRange(IEnumerable<T> entities)
|
||||
{
|
||||
return this.crudDAL.UpdateRange(entities);
|
||||
int result = 0;
|
||||
foreach (var item in entities)
|
||||
{
|
||||
result += Update(item);
|
||||
}
|
||||
return result;// this.crudDAL.UpdateRange(entities);
|
||||
}
|
||||
|
||||
public int CreateOrUpdateAll(IEnumerable<T> entities)
|
||||
{
|
||||
int result = 0;
|
||||
foreach (var item in entities)
|
||||
{
|
||||
result += CreateOrUpdate(item,out string id);
|
||||
}
|
||||
return result;// this.crudDAL.UpdateRange(entities);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,16 @@ namespace WebAPI.Logics.Core
|
||||
public class LogicService
|
||||
{
|
||||
private readonly IServiceScopeFactory serviceScopeFactory;
|
||||
private readonly IdentityService identityService;
|
||||
|
||||
public LogicService(
|
||||
//ChurchNetContext dbContext
|
||||
IServiceScopeFactory serviceScopeFactory
|
||||
IServiceScopeFactory serviceScopeFactory,
|
||||
IdentityService identityService
|
||||
)
|
||||
{
|
||||
this.serviceScopeFactory = serviceScopeFactory;
|
||||
this.identityService = identityService;
|
||||
//DbContext = dbContext;
|
||||
}
|
||||
|
||||
@@ -22,11 +25,7 @@ namespace WebAPI.Logics.Core
|
||||
{
|
||||
get
|
||||
{
|
||||
using (var scope = serviceScopeFactory.CreateScope())
|
||||
{
|
||||
var service = scope.ServiceProvider.GetService<IdentityService>();
|
||||
return service.UserId;
|
||||
}
|
||||
return identityService.UserId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
using Church.Net.DAL.EFCoreDBF;
|
||||
using Church.Net.Entity;
|
||||
using Church.Net.Utility;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Linq;
|
||||
|
||||
namespace WebAPI.Logics
|
||||
{
|
||||
public class HappinessGroupLogic
|
||||
{
|
||||
private readonly ICrudDAL<HappinessGroup> groupCrudDAL;
|
||||
private readonly ICrudDAL<HappinessWeek> weekCrudDAL;
|
||||
string[] weekTitles = new string[] { "真幸福", "真相大白", "萬世巨星", "幸福連線", "當上帝來敲門", "十字架的勝利", "釋放與自由", "幸福的教會" };
|
||||
|
||||
public HappinessGroupLogic(
|
||||
ICrudDAL<HappinessGroup> groupCrudDAL,
|
||||
ICrudDAL<HappinessWeek> weekCrudDAL
|
||||
)
|
||||
{
|
||||
this.groupCrudDAL = groupCrudDAL;
|
||||
this.weekCrudDAL = weekCrudDAL;
|
||||
}
|
||||
|
||||
public List<HappinessGroup> GetAllGroups()
|
||||
{
|
||||
var list = groupCrudDAL.GetDbSet().Include(g => g.BestList).Include(g => g.Weeks).ToList();
|
||||
|
||||
foreach (var group in list)
|
||||
{
|
||||
if (group.Weeks == null || group.Weeks.Count() == 0)
|
||||
{
|
||||
group.Weeks = new List<HappinessWeek>();
|
||||
for (int i = 1; i <= 8; i++)
|
||||
{
|
||||
var week = GetHappinessWeek(group, i);
|
||||
group.Weeks.Add(week);
|
||||
weekCrudDAL.CreateOrUpdate(week);
|
||||
}
|
||||
}
|
||||
group.Weeks = group.Weeks.OrderBy(w => w.SEQ).ToList();
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int UpdateWeekInfo(HappinessWeek value)
|
||||
{
|
||||
if (value.UpdateRestWeekDate)
|
||||
{
|
||||
var list = weekCrudDAL.GetAll(week => week.SEQ >= value.SEQ && week.GroupId == value.GroupId).OrderBy(w => w.SEQ).ToList();
|
||||
var tempDate = new DateTime(value.Date.Year, value.Date.Month, value.Date.Day, value.Date.Hour, value.Date.Minute, value.Date.Second);
|
||||
int count = 0;
|
||||
foreach (var week in list)
|
||||
{
|
||||
week.Date = tempDate.AddDays(count * 7);
|
||||
week.Address = value.Address;
|
||||
week.CityAndZipCode = value.CityAndZipCode;
|
||||
week.InvitationText = value.InvitationText;
|
||||
count++;
|
||||
}
|
||||
return weekCrudDAL.UpdateRange(list);
|
||||
}
|
||||
return weekCrudDAL.CreateOrUpdate(value);
|
||||
|
||||
}
|
||||
|
||||
private HappinessWeek GetHappinessWeek(HappinessGroup group, int weekNo)
|
||||
{
|
||||
return new HappinessWeek()
|
||||
{
|
||||
GroupId = group.Id,
|
||||
Address = group.Address,
|
||||
CityAndZipCode = group.CityAndZipCode,
|
||||
Date = group.BeginTime.AddDays(7 * (weekNo - 1)),
|
||||
SEQ = weekNo
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,11 @@ namespace WebAPI.Logics.Interface
|
||||
int Create(T entity);
|
||||
Task<int> CreateAsync(T entity);
|
||||
//string CreateReturnId(T entity);
|
||||
|
||||
int CreateOrUpdate(T entity, out string id);
|
||||
int CreateOrUpdateAll(IEnumerable<T> entities);
|
||||
int Update(T entity);
|
||||
void CreateDone(T entity);
|
||||
void UpdateDone(T entity);
|
||||
int CreateDone(T entity);
|
||||
int UpdateDone(T entity);
|
||||
int UpdateRange(IEnumerable<T> entities);
|
||||
int Delete(T obj);
|
||||
int Delete(Func<T, bool> filter = null);
|
||||
|
||||
@@ -11,36 +11,27 @@ namespace WebAPI.Logics
|
||||
{
|
||||
public class LineMessagingAccountLogic : LogicBase<LineMessagingAccount>, ICrudLogic<LineMessagingAccount>
|
||||
{
|
||||
private readonly ICrudDAL<HappinessGroup> happinessGroupDAL;
|
||||
private readonly ICrudDAL<PastoralDomain> cellGroupDAL;
|
||||
|
||||
public LineMessagingAccountLogic(
|
||||
LogicService logicService,
|
||||
ICrudDAL<LineMessagingAccount> crudDAL,
|
||||
ICrudDAL<HappinessGroup> happinessGroupDAL,
|
||||
ICrudDAL<PastoralDomain> cellGroupDAL
|
||||
) : base(logicService, crudDAL)
|
||||
{
|
||||
this.happinessGroupDAL = happinessGroupDAL;
|
||||
this.cellGroupDAL = cellGroupDAL;
|
||||
}
|
||||
|
||||
public HappinessGroup GetHappinessGroup(string lineGroupId)
|
||||
{
|
||||
var group= happinessGroupDAL.First(c => c.CommunityAppId == lineGroupId);
|
||||
GetLineMessagingAccount(group);
|
||||
return group;
|
||||
}
|
||||
public PastoralDomain GetCellGroup(string lineGroupId)
|
||||
{
|
||||
var group = cellGroupDAL.First(c => c.CommunityAppId == lineGroupId);
|
||||
var group = cellGroupDAL.First(c => c.LineGroupId == lineGroupId);
|
||||
GetLineMessagingAccount(group);
|
||||
return group;
|
||||
}
|
||||
|
||||
private void GetLineMessagingAccount(IMessengerClient messengerClient)
|
||||
public void GetLineMessagingAccount(IMessengerClient messengerClient)
|
||||
{
|
||||
if (messengerClient != null)
|
||||
if (messengerClient != null && messengerClient.LineAccountId != null)
|
||||
{
|
||||
messengerClient.LineMessagingAccount = crudDAL.GetById(messengerClient.LineAccountId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
using Church.Net.DAL.EFCoreDBF;
|
||||
using Church.Net.Entity;
|
||||
using Church.Net.Utility;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using WebAPI.Logics.Core;
|
||||
using WebAPI.Logics.Interface;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace WebAPI.Logics
|
||||
{
|
||||
public class PastoralDomainLogic : LogicBase<PastoralDomain>, ICrudLogic<PastoralDomain>
|
||||
{
|
||||
string[] weekTopics = new string[] { "真幸福", "真相大白", "萬世巨星", "幸福連線", "當上帝來敲門", "十字架的勝利", "釋放與自由", "幸福的教會" };
|
||||
private readonly IServiceScopeFactory serviceScopeFactory;
|
||||
private readonly ICrudDAL<CellGroupRoutineEvent> eventCrudDAL;
|
||||
private readonly ICombinedKeyCrudDAL<CellGroupRoutineEventAttendee> attendeeCrudDAL;
|
||||
private readonly ICrudDAL<FamilyMember> memberCrudDAL;
|
||||
private readonly ICrudDAL<AddressInfo> addressCrudDAL;
|
||||
private readonly ICombinedKeyCrudDAL<PastoralDomainMembers> pastoralDomainMemberDAL;
|
||||
private readonly ICrudDAL<HappinessWeek> weekCrudDAL;
|
||||
private readonly ICrudDAL<HappinessBEST> bestCrudDAL;
|
||||
private readonly ICrudDAL<HappinessTask> weekTaskCrudDAL;
|
||||
|
||||
public PastoralDomainLogic(
|
||||
IServiceScopeFactory serviceScopeFactory,
|
||||
LogicService logicService,
|
||||
ICrudDAL<PastoralDomain> crudDAL,
|
||||
ICrudDAL<CellGroupRoutineEvent> eventCrudDAL,
|
||||
ICombinedKeyCrudDAL<CellGroupRoutineEventAttendee> attendeeCrudDAL,
|
||||
ICrudDAL<FamilyMember> memberCrudDAL,
|
||||
ICrudDAL<AddressInfo> addressCrudDAL,
|
||||
ICombinedKeyCrudDAL<PastoralDomainMembers> pastoralDomainMemberDAL,
|
||||
ICrudDAL<HappinessWeek> weekCrudDAL,
|
||||
ICrudDAL<HappinessBEST> bestCrudDAL,
|
||||
ICrudDAL<HappinessTask> weekTaskCrudDAL
|
||||
) : base(logicService, crudDAL)
|
||||
{
|
||||
this.serviceScopeFactory = serviceScopeFactory;
|
||||
this.eventCrudDAL = eventCrudDAL;
|
||||
this.attendeeCrudDAL = attendeeCrudDAL;
|
||||
this.memberCrudDAL = memberCrudDAL;
|
||||
this.addressCrudDAL = addressCrudDAL;
|
||||
this.pastoralDomainMemberDAL = pastoralDomainMemberDAL;
|
||||
this.weekCrudDAL = weekCrudDAL;
|
||||
this.bestCrudDAL = bestCrudDAL;
|
||||
this.weekTaskCrudDAL = weekTaskCrudDAL;
|
||||
}
|
||||
|
||||
|
||||
#region override
|
||||
|
||||
|
||||
public override IEnumerable<PastoralDomain> GetAll(Func<PastoralDomain, bool> filter = null)
|
||||
{
|
||||
var list = base.GetAll(filter);
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.ServiceAddressId))
|
||||
{
|
||||
item.ServiceAddress = addressCrudDAL.GetById(item.ServiceAddressId);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.ServiceAddress = new AddressInfo();
|
||||
}
|
||||
if (item.Type == DomainType.HappinessGroup)
|
||||
{
|
||||
GetHappinessGroupInfo(item);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public override void BeforeCreate(PastoralDomain entity)
|
||||
{
|
||||
addressCrudDAL.CreateOrUpdate(entity.ServiceAddress);
|
||||
entity.ServiceAddressId = entity.ServiceAddress.Id;
|
||||
}
|
||||
public override void BeforeUpdate(PastoralDomain entity)
|
||||
{
|
||||
addressCrudDAL.CreateOrUpdate(entity.ServiceAddress);
|
||||
entity.ServiceAddressId = entity.ServiceAddress.Id;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public CellGroupRoutineEvent GetComingEvent(string domainId = null)
|
||||
{
|
||||
if (domainId == null)
|
||||
{
|
||||
var cellGroup = GetCurrentUserCellGroup();
|
||||
if (cellGroup != null)
|
||||
{
|
||||
domainId = cellGroup.Id;
|
||||
|
||||
var _event = eventCrudDAL.GetDbSet().OrderByDescending(e => e.Time)
|
||||
.Include(e => e.Attendees).Include(e => e.Prayers)
|
||||
.Where(e => e.PastoralDomainId == domainId).FirstOrDefault();
|
||||
return _event;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (domainId != null)
|
||||
{
|
||||
var _event = eventCrudDAL.GetDbSet().Where(e => e.PastoralDomainId == domainId && e.Time >= DateTime.UtcNow)
|
||||
.Include(e => e.Attendees).Include(e => e.Prayers).FirstOrDefault();
|
||||
if (_event == null)
|
||||
{
|
||||
_event = new CellGroupRoutineEvent()
|
||||
{
|
||||
Id = Format.Get33BaseGuid(),
|
||||
Time = DateTimeHelper.GetNextWeekday(DateTime.Today, DayOfWeek.Friday).AddHours(19).AddMinutes(30),
|
||||
Address = "1881 Forest Dr., Azusa, CA 91702",
|
||||
Attendees = new List<CellGroupRoutineEventAttendee>(),
|
||||
PastoralDomainId = domainId
|
||||
};
|
||||
eventCrudDAL.Create(_event);
|
||||
}
|
||||
|
||||
return _event;
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public CellGroupRoutineEvent GetLastEvent(string domainId = null)
|
||||
{
|
||||
if (domainId == null)
|
||||
{
|
||||
var cellGroup = GetCurrentUserCellGroup();
|
||||
if (cellGroup != null)
|
||||
{
|
||||
domainId = cellGroup.Id;
|
||||
|
||||
var _event = eventCrudDAL.GetDbSet().OrderByDescending(e => e.Time)
|
||||
.Include(e => e.Attendees).Include(e => e.Prayers)
|
||||
.Where(e => e.PastoralDomainId == domainId).FirstOrDefault();
|
||||
return _event;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (domainId != null)
|
||||
{
|
||||
var _event = eventCrudDAL.GetDbSet().OrderByDescending(e => e.Time)
|
||||
.Include(e => e.Attendees).Include(e => e.Prayers)
|
||||
.Where(e => e.PastoralDomainId == domainId).FirstOrDefault();
|
||||
return _event;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetMemberFirstNameById(string memberId)
|
||||
{
|
||||
return memberCrudDAL.GetById(memberId)?.FirstName;
|
||||
}
|
||||
|
||||
public IEnumerable<PastoralDomain> GetCurrentUserPastoralDomain()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(logicService.CurrentUserId))
|
||||
{
|
||||
var ids = pastoralDomainMemberDAL.GetAll(p => p.FamilyMemberId == logicService.CurrentUserId).Select(p => p.PastoralDomainId);
|
||||
return crudDAL.GetAll(p => ids.Contains(p.Id));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public PastoralDomain GetCurrentUserCellGroup()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(logicService.CurrentUserId))
|
||||
{
|
||||
var ids = pastoralDomainMemberDAL.GetAll(p => p.FamilyMemberId == logicService.CurrentUserId).Select(p => p.PastoralDomainId);
|
||||
return crudDAL.GetAll(p => ids.Contains(p.Id) && p.Type == DomainType.CellGroup).FirstOrDefault();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public int UpdateWeekInfo(HappinessWeek value)
|
||||
{
|
||||
if (value.UpdateRestWeekDate)
|
||||
{
|
||||
var list = weekCrudDAL.GetAll(week => week.SEQ >= value.SEQ && week.GroupId == value.GroupId).OrderBy(w => w.SEQ).ToList();
|
||||
var tempDate = new DateTime(value.Date.Year, value.Date.Month, value.Date.Day, value.Date.Hour, value.Date.Minute, value.Date.Second);
|
||||
int count = 0;
|
||||
foreach (var week in list)
|
||||
{
|
||||
week.Date = tempDate.AddDays(count * 7);
|
||||
week.Address = value.Address;
|
||||
week.CityAndZipCode = value.CityAndZipCode;
|
||||
week.InvitationText = value.InvitationText;
|
||||
count++;
|
||||
}
|
||||
return weekCrudDAL.UpdateRange(list);
|
||||
}
|
||||
return weekCrudDAL.CreateOrUpdate(value);
|
||||
|
||||
}
|
||||
|
||||
private HappinessWeek GetHappinessWeek(PastoralDomain group, int weekNo)
|
||||
{
|
||||
return new HappinessWeek()
|
||||
{
|
||||
GroupId = group.Id,
|
||||
Address = group.ServiceAddress.Address,
|
||||
CityAndZipCode = group.ServiceAddress.GetCSZ(),
|
||||
Date = group.ServiceTime.Value.AddDays(7 * (weekNo - 1)),
|
||||
SEQ = weekNo
|
||||
};
|
||||
}
|
||||
public void GetHappinessGroupInfo(PastoralDomain group)
|
||||
{
|
||||
group.HappinessWeeks = weekCrudDAL.GetAll(w => w.GroupId == group.Id).OrderBy(w => w.SEQ).ToList();
|
||||
if (group.HappinessWeeks == null || group.HappinessWeeks.Count() == 0)
|
||||
{
|
||||
group.HappinessWeeks = new List<HappinessWeek>();
|
||||
for (int i = 1; i <= 8; i++)
|
||||
{
|
||||
var week = GetHappinessWeek(group, i);
|
||||
group.HappinessWeeks.Add(week);
|
||||
weekCrudDAL.CreateOrUpdate(week);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var week in group.HappinessWeeks)
|
||||
{
|
||||
week.Topic = weekTopics[week.SEQ - 1];
|
||||
week.Tasks = weekTaskCrudDAL.GetAll(t => t.WeekId == week.Id).ToList();
|
||||
}
|
||||
|
||||
group.Bests = bestCrudDAL.GetAll(b => b.GroupId == group.Id).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user