/// <summary> /// creates a brand new dues object for a league. /// </summary> /// <param name="ownerId"></param> /// <param name="ownerType"></param> public static void CreateDuesObject(Guid ownerId, DuesOwnerEntityEnum ownerType) { try { var dc = new ManagementContext(); FeeManagement fee = new FeeManagement(); fee.DayOfMonthToCollectDefault = 15; fee.DaysBeforeDeadlineToNotifyDefault = 10; fee.FeeCostDefault = 45.00; fee.LeagueOwner = dc.Leagues.Where(x => x.LeagueId == ownerId).FirstOrDefault(); fee.EmailResponse = String.Empty; fee.AcceptPaymentsOnline = false; fee.WhoPaysProcessorFeesEnum = Convert.ToInt32(WhoPaysProcessorFeesEnum.Sender); fee.FeeTypeEnum = Convert.ToInt32(Enums.FeesTypeEnum.DuesType); FeeItem item = new FeeItem(); item.CostOfFee = 45.00; item.DaysBeforeDeadlineToNotify = 10; item.FeeManagedBy = fee; item.Notified = false; item.PayBy = DateTime.UtcNow.AddDays(15); fee.Fees.Add(item); dc.FeeManagement.Add(fee); dc.SaveChanges(); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } }
private static DuesPortableModel DisplayDuesSettings(FeeManagement dues) { try { DuesPortableModel due = new DuesPortableModel(); due.DayOfMonthToCollectDefault = dues.DayOfMonthToCollectDefault; due.DaysBeforeDeadlineToNotifyDefault = dues.DaysBeforeDeadlineToNotifyDefault; due.DuesCost = dues.FeeCostDefault; due.DuesCostDisplay = dues.FeeCostDefault.ToString("N2"); due.DuesId = dues.FeeManagementId; due.LeagueOwnerId = dues.LeagueOwner.LeagueId; due.LeagueOwnerName = dues.LeagueOwner.Name; if (dues.LeagueOwner.ContactCard != null && dues.LeagueOwner.ContactCard.Emails.FirstOrDefault() != null) due.LeagueEmailAddress = dues.LeagueOwner.ContactCard.Emails.Where(x => x.IsDefault == true).FirstOrDefault().EmailAddress; due.OwnerEntity = Enums.DuesOwnerEntityEnum.league.ToString(); due.AcceptPaymentsOnline = dues.AcceptPaymentsOnline; due.PayPalEmailAddress = dues.PayPalEmailAddress; due.WhoPaysProcessorFeesEnum = (WhoPaysProcessorFeesEnum)Enum.Parse(typeof(WhoPaysProcessorFeesEnum), dues.WhoPaysProcessorFeesEnum.ToString()); due.LockDownManagementToManagersOnly = dues.LockDownManagementToManagersOnly; return due; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return null; }
/// <summary> /// creates a new fee item from the automatedtasks class. /// </summary> /// <param name="monthAhead"></param> /// <param name="fee"></param> public static void CreateNewFeeItem(DateTime monthAhead, FeeManagement fee) { var dc = new ManagementContext(); var mana = dc.FeeManagement.Where(x => x.FeeManagementId == fee.FeeManagementId).FirstOrDefault(); FeeItem fItem = new FeeItem(); fItem.CostOfFee = fee.FeeCostDefault; fItem.FeeManagedBy = mana; fItem.PayBy = monthAhead; fItem.Notified = false; fItem.DaysBeforeDeadlineToNotify = fee.DaysBeforeDeadlineToNotifyDefault; mana.Fees.Add(fItem); dc.SaveChanges(); }