WIP
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using Church.Net.DAL.EFCoreDBF;
|
||||
using Church.Net.Entity;
|
||||
using WebAPI.Logics.Core;
|
||||
using WebAPI.Logics.Interface;
|
||||
|
||||
namespace WebAPI.Logics
|
||||
{
|
||||
public class MemberLogic : LogicBase<FamilyMember>, ICrudLogic<FamilyMember>
|
||||
{
|
||||
public MemberLogic(
|
||||
LogicService logicService,
|
||||
ICrudDAL<FamilyMember> crudDAL
|
||||
) : base(logicService, crudDAL)
|
||||
{
|
||||
}
|
||||
|
||||
public override void BeforeUpdate(FamilyMember entity)
|
||||
{
|
||||
|
||||
entity.Password = crudDAL.First(m => m.Id == entity.Id).Password;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,37 +17,40 @@ namespace WebAPI.Logics
|
||||
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;
|
||||
private readonly ICrudDAL<HappinessCost> happinessCostCrudDAL;
|
||||
private readonly ICrudDAL<Contribution> contributionCrudDAL;
|
||||
|
||||
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
|
||||
ICrudDAL<HappinessTask> weekTaskCrudDAL,
|
||||
ICrudDAL<Contribution> contributionCrudDALL,
|
||||
ICrudDAL<HappinessCost> happinessCostCrudDAL
|
||||
) : 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;
|
||||
this.happinessCostCrudDAL = happinessCostCrudDAL;
|
||||
this.contributionCrudDAL = contributionCrudDALL;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,20 +60,26 @@ namespace WebAPI.Logics
|
||||
public override IEnumerable<PastoralDomain> GetAll(Func<PastoralDomain, bool> filter = null)
|
||||
{
|
||||
var list = base.GetAll(filter);
|
||||
foreach (var item in list)
|
||||
foreach (var group in list)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.ServiceAddressId))
|
||||
if (!string.IsNullOrEmpty(group.ServiceAddressId))
|
||||
{
|
||||
item.ServiceAddress = addressCrudDAL.GetById(item.ServiceAddressId);
|
||||
group.ServiceAddress = addressCrudDAL.GetById(group.ServiceAddressId);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.ServiceAddress = new AddressInfo();
|
||||
group.ServiceAddress = new AddressInfo();
|
||||
}
|
||||
if (item.Type == DomainType.HappinessGroup)
|
||||
if (group.Type == DomainType.HappinessGroup)
|
||||
{
|
||||
GetHappinessGroupInfo(item);
|
||||
GetHappinessGroupInfo(group);
|
||||
}
|
||||
|
||||
group.FamilyMembers =
|
||||
memberCrudDAL.GetAllById(
|
||||
pastoralDomainMemberDAL.GetAll(d => d.PastoralDomainId == group.Id).Select(d => d.FamilyMemberId).ToList()
|
||||
).ToList();
|
||||
group.Contributions = contributionCrudDAL.GetAll(d => d.GroupId == group.Id).ToList();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -91,31 +100,42 @@ namespace WebAPI.Logics
|
||||
|
||||
public CellGroupRoutineEvent GetComingEvent(string domainId = null)
|
||||
{
|
||||
PastoralDomain cellGroup;
|
||||
if (domainId == null)
|
||||
{
|
||||
var cellGroup = GetCurrentUserCellGroup();
|
||||
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;
|
||||
//var _event = eventCrudDAL.GetDbSet().OrderByDescending(e => e.Time)
|
||||
// .Include(e => e.Attendees).Include(e => e.Prayers)
|
||||
// .Where(e => e.PastoralDomainId == domainId).FirstOrDefault();
|
||||
//return _event;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
cellGroup= crudDAL.GetById(domainId);
|
||||
}
|
||||
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)
|
||||
{
|
||||
var serviceLocalTime = cellGroup.ServiceTime.Value.ToUniversalTime().ToLocal(cellGroup.TimeZone);
|
||||
var serviceWeekDay = serviceLocalTime.DayOfWeek;
|
||||
var nextServiceTime = DateTimeHelper.GetNextWeekday(DateTimeHelper.Today(cellGroup.TimeZone), DayOfWeek.Friday)
|
||||
.AddHours(serviceLocalTime.Hour).AddMinutes(serviceLocalTime.Minute);
|
||||
|
||||
|
||||
_event = new CellGroupRoutineEvent()
|
||||
{
|
||||
Id = Format.Get33BaseGuid(),
|
||||
Time = DateTimeHelper.GetNextWeekday(DateTime.Today, DayOfWeek.Friday).AddHours(19).AddMinutes(30),
|
||||
Time = nextServiceTime.ToUtc(cellGroup.TimeZone),
|
||||
Address = "1881 Forest Dr., Azusa, CA 91702",
|
||||
Attendees = new List<CellGroupRoutineEventAttendee>(),
|
||||
PastoralDomainId = domainId
|
||||
@@ -167,7 +187,17 @@ namespace WebAPI.Logics
|
||||
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));
|
||||
var list = crudDAL.GetAll(p => ids.Contains(p.Id));
|
||||
|
||||
foreach (var group in list)
|
||||
{
|
||||
if (group.Type == DomainType.HappinessGroup)
|
||||
{
|
||||
GetHappinessGroupInfo(group);
|
||||
}
|
||||
group.Contributions = contributionCrudDAL.GetAll(d => d.GroupId == group.Id).ToList();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -231,10 +261,11 @@ namespace WebAPI.Logics
|
||||
foreach (var week in group.HappinessWeeks)
|
||||
{
|
||||
week.Topic = weekTopics[week.SEQ - 1];
|
||||
week.Tasks = weekTaskCrudDAL.GetAll(t => t.WeekId == week.Id).ToList();
|
||||
week.Tasks = weekTaskCrudDAL.GetAll(t => t.WeekId == week.Id).OrderBy(t => t.Type).ToList();
|
||||
week.Costs = happinessCostCrudDAL.GetAll(t => t.WeekId == week.Id).ToList();
|
||||
}
|
||||
|
||||
group.Bests = bestCrudDAL.GetAll(b => b.GroupId == group.Id).ToList();
|
||||
group.Bests = bestCrudDAL.GetAll(b => b.GroupId == group.Id).OrderBy(b => b.Name).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user