/// <summary> /// Resolves the dependent models by means of updating all models that reference this model. /// </summary> protected override void ResolveDependent() { base.ResolveDependent(); if (_currentPeriod != null && _currentPeriod.IsModified) { _currentPeriod.MemIdId = this.Id; _currentPeriod.Save(); } }
/// <summary> /// Resolves the dependencies by means of persisting all models that this model is referencing. /// </summary> protected override void ResolveGeneratedDependency() { base.ResolveGeneratedDependency(); if (_membership != null) { _membership.Save(); this.ModifiedData.MemId = _membership.Id == null && this.ModifiedData.MemId != null ? "" : _membership.Id; } if (_memberPeriod != null) { _memberPeriod.Save(); this.ModifiedData.MepId = _memberPeriod.Id == null && this.ModifiedData.MepId != null ? "" : _memberPeriod.Id; } if (_orgId != null) { _orgId.Save(); this.ModifiedData.OrgId = _orgId.Id == null && this.ModifiedData.OrgId != null ? "" : _orgId.Id; } if (_role != null) { _role.Save(); this.ModifiedData.ProleId = _role.Id == null && this.ModifiedData.ProleId != null ? "" : _role.Id; } if (_mailAddId != null) { _mailAddId.Save(); this.ModifiedData.MailAddId = _mailAddId.Id == null && this.ModifiedData.MailAddId != null ? "" : _mailAddId.Id; } if (_mailInvId != null) { _mailInvId.Save(); this.ModifiedData.MailInvId = _mailInvId.Id == null && this.ModifiedData.MailInvId != null ? "" : _mailInvId.Id; } if (_invlnId != null) { _invlnId.Save(); this.ModifiedData.InvlnId = _invlnId.Id == null && this.ModifiedData.InvlnId != null ? "" : _invlnId.Id; } if (_product != null) { _product.Save(); this.ModifiedData.ProdId = _product.Id == null && this.ModifiedData.ProdId != null ? "" : _product.Id; } if (_plId != null) { _plId.Save(); this.ModifiedData.PlId = _plId.Id == null && this.ModifiedData.PlId != null ? "" : _plId.Id; } }
/// <summary> /// Performs rollback membership on a single <see cref='MemberPeriodModel' /> instance. /// Functionality replicated from the SQL performed in V6.5 /// </summary> /// <param name="memberPeriodId"> /// The value which identifies the <see cref='MemberPeriodModel' /> instance to be modified. /// </param> /// <param name="status"> /// The status value which should be set. /// </param> /// <returns> /// The <see cref='MemberPeriodModel' /> instance that match the specified <paramref name='memberPeriodId' />. /// </returns> public LocalMemberPeriodModel RollbackMembership(String memberPeriodId, String status) { //Create credit notes for any associated invoices foreach (InvheaderRecord invoice in (this.Provider.DataProvider.Finance.Invoice.FetchAllByMepId(memberPeriodId).Where(i => i.Type != "Credit" && i.NetTotal > 0))) { if (this.Provider.DataProvider.Finance.InvoiceLine.FetchAllByInvId(invoice.Id).Where(line => line.Credited == 1).Count() == 0) { this.Provider.DataProvider.Finance.Invoice.RollbackInvoice(invoice); } } //Update Rollback Date and status for memberperiod record LocalMemberPeriodModel memberPeriod = this.Provider.Membership.MemberPeriod.FetchById(memberPeriodId); memberPeriod.RollbackDate = DateTime.UtcNow; memberPeriod.StatusCode = status; memberPeriod.Save(); //Reset status on old member period record if required LocalMemberPeriodModel oldMemberPeriod = this.Provider.Membership.MemberPeriod.FetchById(memberPeriod.OldMepId); if (oldMemberPeriod != null && oldMemberPeriod.StatusCode != null) { string oldStatus = oldMemberPeriod.StatusCode; if (oldStatus.Substring(0, 2) == "90" && (status.Substring(0, 2) == "13" || status.Substring(0, 2) == "14" || status.Substring(0, 2) == "15" || status.Substring(0, 2) == "16")) { oldMemberPeriod.StatusCode = "25-Current Renewing"; oldMemberPeriod.Save(); } } //Reset invoiced status on member location records LocalMemberLocationModel[] memberLocations = memberPeriod.MemberLocations.Where(loc => loc.Invoiced == 1).ToArray(); if (memberLocations.Count() > 0) { memberLocations.Execute(loc => loc.Invoiced = 0).Execute(loc => loc.Save()); } return(memberPeriod); }