Esempio n. 1
0
        void PullDues()
        {
            Dispatcher.BeginInvoke(delegate
            {
                progressIndicator.IsVisible = true;
            });
            try
            {
                Task.Run(new Action(() =>
                {
                    duesModel = DuesMobile.GetDuesManagement(SettingsMobile.Instance.User.MemberId, SettingsMobile.Instance.User.LoginId);

                    Dispatcher.BeginInvoke(delegate
                    {
                       
                        DuesList.ItemsSource = duesModel.DuesFees;
                        progressIndicator.IsVisible = false;
                    });

                }));

            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.WP8);
            }
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            try
            {
                if (e.NavigationMode == NavigationMode.New)
                {
                    dues = new DuesPortableModel();
                    //(App.Current as App).SecondPageObject = null;
                    progressIndicator = SystemTray.ProgressIndicator;
                    progressIndicator = new ProgressIndicator();
                    SystemTray.SetProgressIndicator(this, progressIndicator);
                    progressIndicator.IsIndeterminate = true;
                    progressIndicator.Text = "Pulling Dues Settings...";
                    duesId = new Guid(this.NavigationContext.QueryString["dmid"]);
                    if (SettingsMobile.Instance.User == null)
                    {
                        SqlFactory fact = new SqlFactory();
                        SettingsMobile.Instance.User = fact.GetProfile();
                    }

                    PullTopic();
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.WP8);
            }
        }
        public ActionResult DuesManagementByMember()
        {
            try
            {
                if (HttpContext.Request.InputStream != null)
                {
                    Stream stream = HttpContext.Request.InputStream;
                    var ob = Network.LoadObject<DuesSendParams>(ref stream);
                    var mem = MemberCache.GetMemberDisplay(ob.CurrentMemberId);
                    if (ob.UserId == mem.UserId)
                    {
                        DuesPortableModel dues = new DuesPortableModel();
                        dues.LeagueOwnerId = mem.CurrentLeagueId;
                        var dues2 = DuesFactory.GetDuesObject(mem.CurrentLeagueId, ob.CurrentMemberId);
                        if (dues2.DuesId != new Guid())
                            dues = dues2;
                        dues.IsSuccessful = true;
                        return Json(dues, JsonRequestBehavior.AllowGet);
                    }

                }
            }
            catch (Exception e)
            {
                ErrorDatabaseManager.AddException(e, GetType());

            }
            return Json(new DuesPortableModel() { IsSuccessful = false }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 4
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            try
            {
                duesModel = new DuesPortableModel();

                //(App.Current as App).SecondPageObject = null;
                progressIndicator = SystemTray.ProgressIndicator;
                progressIndicator = new ProgressIndicator();
                SystemTray.SetProgressIndicator(this, progressIndicator);
                progressIndicator.IsIndeterminate = true;
                progressIndicator.Text = "Pulling Dues...";
                if (SettingsMobile.Instance.User == null)
                {
                    SqlFactory fact = new SqlFactory();
                    SettingsMobile.Instance.User = fact.GetProfile();
                }
                if (SettingsMobile.Instance.AccountSettings.IsTreasurer)
                {
                    ApplicationBar.IsVisible = true;
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.WP8);
            }


            PullDues();
        }
        void PullTopic()
        {
            Dispatcher.BeginInvoke(delegate
            {
                progressIndicator.IsVisible = true;
                progressIndicator.Text = "Pulling Dues Item...";
            });

            Task.Run(new Action(() =>
            {
                try
                {
                    dues = DuesMobile.GetDuesItem(SettingsMobile.Instance.User.MemberId, SettingsMobile.Instance.User.LoginId, duesId, duesItemId);
                    item = dues.DuesFees.FirstOrDefault();
                    Members = new ObservableCollection<MemberDisplayDues>(dues.Members);
                    Dispatcher.BeginInvoke(delegate
                    {
                        Title.Title = item.PayBy.ToLongDateString();
                        DueDate.Text = item.PayBy.ToLongDateString();
                        AmountDue.Text = item.CostOfDues.ToString("N2");
                        RosterList.ItemsSource = Members;

                        progressIndicator.IsVisible = false;
                    });
                }
                catch (Exception exception)
                {
                    ErrorHandler.Save(exception, MobileTypeEnum.WP8);
                }
            }));


        }
 public static DuesPortableModel SaveDuesSettings(DuesPortableModel model)
 {
     var response = Network.SendPackage(Network.ConvertObjectToStream(model), MobileConfig.LEAGUE_DUES_SAVE_SETTINGS_URL);
     var stream = response.GetResponseStream();
     StreamReader read = new StreamReader(stream);
     string json = read.ReadToEnd();
     return Json.DeserializeObject<DuesPortableModel>(json);
 }
        void PullTopic()
        {
            Dispatcher.BeginInvoke(delegate
            {
                progressIndicator.IsVisible = true;
                progressIndicator.Text = "Pulling Dues Settings...";
            });

            Task.Run(new Action(() =>
            {
                try
                {
                    dues = DuesMobile.GetDuesSettings(SettingsMobile.Instance.User.MemberId, SettingsMobile.Instance.User.LoginId, duesId);
                    Dispatcher.BeginInvoke(delegate
                    {
                        try
                        {
                            DayOfMonthToCollect.Text = dues.DayOfMonthToCollectDefault.ToString();
                            DaysBeforeToNotify.Text = dues.DaysBeforeDeadlineToNotifyDefault.ToString();
                            AmountToCollect.Text = dues.DuesCostDisplay;
                            DuesForManagementOnly.IsChecked = dues.LockDownManagementToManagersOnly;
                            PayPalPaymentsAllowed.IsChecked = dues.AcceptPaymentsOnline;
                            PaypalEmailAddress.Text = dues.PayPalEmailAddress;
                            CurrencySelect.ItemsSource = dues.Currencies;
                            CurrencySelect.SelectedItem = dues.Currencies.Where(x => x.CurrencyAbbrName == dues.Currency).FirstOrDefault();
                            progressIndicator.IsVisible = false;
                        }
                        catch (Exception exception)
                        {
                            ErrorHandler.Save(exception, MobileTypeEnum.WP8);
                        }
                    });
                }
                catch (Exception exception)
                {
                    ErrorHandler.Save(exception, MobileTypeEnum.WP8);
                }
            }));
        }
        public ActionResult DuesManagement()
        {
            try
            {
                if (HttpContext.Request.InputStream != null)
                {
                    Stream stream = HttpContext.Request.InputStream;
                    var ob = Network.LoadObject<DuesSendParams>(ref stream);
                    var mem = MemberCache.GetMemberDisplay(ob.CurrentMemberId);
                    if (ob.UserId == mem.UserId)
                    {
                        DuesPortableModel dues = new DuesPortableModel();
                        dues.LeagueOwnerId = mem.CurrentLeagueId;
                        var dues2 = DuesFactory.GetDuesObject(mem.CurrentLeagueId, ob.CurrentMemberId);
                        if (dues2.DuesId != new Guid())
                            dues = dues2;
                        dues.IsSuccessful = true;
                        return Json(dues, JsonRequestBehavior.AllowGet);
                        //if (MemberCache.IsTreasurerOrBetterOfLeague(memId) && !dues.AcceptPaymentsOnline)
                        //{
                        //    SiteMessage message = new SiteMessage();
                        //    message.MessageType = SiteMessageType.Info;
                        //    message.Message = "Did You know you can accept Dues Payments online?  Go to the settings to get started.";
                        //    this.AddMessage(message);
                        //}
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, GetType());
            }

            return Json(new DuesPortableModel() { IsSuccessful = false }, JsonRequestBehavior.AllowGet);
        }
 public ActionResult DeleteDuesItem(DuesPortableModel duesItem)
 {
     try
     {
         long duesItemId = Convert.ToInt64(HttpContext.Request.Form["DuesItemId"]);
         bool isSuccess = DuesFactory.DeleteDuesCollectionItem(duesItemId, duesItem.DuesId);
         if (!isSuccess)
             return Redirect(Url.Content("~/dues/" + duesItem.OwnerEntity + "/" + duesItem.LeagueOwnerId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.sww));
         return Redirect(Url.Content("~/dues/" + duesItem.OwnerEntity + "/" + duesItem.LeagueOwnerId.ToString().Replace("-", "")));
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, GetType());
     }
     return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
 }
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
        public static DuesPortableModel GetDuesSettings(Guid leagueId, Guid duesId)
        {
            DuesPortableModel due = new DuesPortableModel();
            try
            {
                var dc = new ManagementContext();
                var dues = (from xx in dc.FeeManagement.Include("LeagueOwner")
                            where xx.LeagueOwner.LeagueId == leagueId
                            where xx.FeeManagementId == duesId
                            select new
                            {
                                xx.DayOfMonthToCollectDefault,
                                xx.DaysBeforeDeadlineToNotifyDefault,
                                xx.FeeCostDefault,
                                xx.FeeManagementId,
                                xx.LeagueOwner,
                                xx.WhoPaysProcessorFeesEnum,
                                xx.PayPalEmailAddress,
                                xx.LockDownManagementToManagersOnly,
                                xx.AcceptPaymentsOnline,
                                xx.EmailResponse,
                                xx.CurrencyRate
                            }).FirstOrDefault();


                if (dues != null)
                {
                    if (dues.CurrencyRate != null)
                        due.Currency = dues.CurrencyRate.CurrencyAbbrName;
                    else
                        due.Currency = "USD";
                    due.DuesEmailText = dues.EmailResponse;
                    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;
                    due.OwnerEntity = Enums.DuesOwnerEntityEnum.league.ToString();
                    due.AcceptPaymentsOnline = dues.AcceptPaymentsOnline;
                    due.PayPalEmailAddress = dues.PayPalEmailAddress;
                    due.LockDownManagementToManagersOnly = dues.LockDownManagementToManagersOnly;
                    due.WhoPaysProcessorFeesEnum = (WhoPaysProcessorFeesEnum)Enum.Parse(typeof(WhoPaysProcessorFeesEnum), dues.WhoPaysProcessorFeesEnum.ToString());
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return due;
        }
        public ActionResult DuesItemReport(DuesPortableModel dues)
        {
            var memId = RDN.Library.Classes.Account.User.GetMemberId();
            long duesItemId = Convert.ToInt64(HttpContext.Request.Form["DuesItemId"]);
            var duesItem = DuesFactory.GetDuesCollectionItem(duesItemId, dues.DuesId, memId);
            var Fee = duesItem.DuesFees.FirstOrDefault();
            var league = MemberCache.GetLeagueOfMember(memId);
            if (league != null)
                SetCulture(league.CultureSelected);

            using (ExcelPackage p = new ExcelPackage())
            {
                try
                {
                    p.Workbook.Properties.Author = "RDNation.com";

                    ExcelWorksheet reportSheet = p.Workbook.Worksheets.Add(Fee.PayBy.ToString("yyyy-MM-dd"));
                    reportSheet.Name = Fee.PayBy.ToString("yyyy-MM-dd"); //Setting Sheet's name
                    reportSheet.Cells.Style.Font.Size = 11; //Default font size for whole sheet
                    reportSheet.Cells.Style.Font.Name = "Calibri"; //Default Font name for whole sheet
                    reportSheet.Cells[1, 1].Value = "Member";
                    reportSheet.Cells[1, 2].Value = "Due";
                    reportSheet.Cells[1, 3].Value = "Collected";
                    reportSheet.Cells[1, 4].Value = "Date Collected";

                    int rowReport = 2;
                    //create the remaining sheets with the names.
                    foreach (var attendee in duesItem.Members)
                    {
                        try
                        {
                            reportSheet.Cells[rowReport, 1].Value = attendee.DerbyName;
                            reportSheet.Cells[rowReport, 2].Value = attendee.due;
                            if (attendee.isWaived)
                                reportSheet.Cells[rowReport, 2].Value = "W";
                            reportSheet.Cells[rowReport, 3].Value = attendee.collected;
                            if (attendee.DatePaid != new DateTime() && attendee.DatePaid != null)
                                reportSheet.Cells[rowReport, 4].Value = attendee.DatePaid.ToShortDateString();
                            rowReport += 1;
                        }
                        catch (Exception exception)
                        {
                            ErrorDatabaseManager.AddException(exception, exception.GetType());
                        }
                    }
                    reportSheet.Cells[rowReport, 2].Formula = "=sum(b2:b" + (rowReport - 1) + ")";
                    reportSheet.Cells[rowReport, 3].Formula = "=sum(c2:c" + (rowReport - 1) + ")";
                    reportSheet.Cells["A1:K20"].AutoFitColumns();
                }
                catch (Exception exception)
                {
                    ErrorDatabaseManager.AddException(exception, exception.GetType());
                }
                //Generate A File with Random name
                Byte[] bin = p.GetAsByteArray();
                string file = Fee.PayBy.ToString("yyyy-MM-dd") + RDN.Utilities.Strings.StringExt.ToExcelFriendly(" Dues Report " + duesItem.LeagueOwnerName) + "_" + Fee.PayBy.ToString("yyyymmdd") + ".xlsx";
                return File(bin, RDN.Utilities.IO.FileExt.GetMIMEType(file), file);
            }
        }
        public ActionResult DuesPersonalReport(DuesPortableModel dues)
        {

            var memId = RDN.Library.Classes.Account.User.GetMemberId();
            var duesItem = DuesFactory.GetDuesObject(dues.LeagueOwnerId, memId);


            using (ExcelPackage p = new ExcelPackage())
            {
                try
                {
                    p.Workbook.Properties.Author = "RDNation.com";

                    ExcelWorksheet duesPaidSheet = p.Workbook.Worksheets.Add(RDN.Utilities.Strings.StringExt.ToExcelFriendly("Dues Paid"));
                    ExcelWorksheet duesNotPaidSheet = p.Workbook.Worksheets.Add(RDN.Utilities.Strings.StringExt.ToExcelFriendly("Dues Not Paid"));
                    duesPaidSheet.Name = "Dues Paid"; //Setting Sheet's name
                    duesPaidSheet.Cells.Style.Font.Size = 11; //Default font size for whole sheet
                    duesPaidSheet.Cells.Style.Font.Name = "Calibri"; //Default Font name for whole sheet
                    duesPaidSheet.Cells[1, 1].Value = "Member";

                    duesNotPaidSheet.Name = "Dues Not Paid"; //Setting Sheet's name
                    duesNotPaidSheet.Cells.Style.Font.Size = 11; //Default font size for whole sheet
                    duesNotPaidSheet.Cells.Style.Font.Name = "Calibri"; //Default Font name for whole sheet
                    duesNotPaidSheet.Cells[1, 1].Value = "Member";

                    int column = 2;
                    int rowReport = 2;
                    //create the remaining sheets with the names.
                    foreach (var attendee in duesItem.Members.Where(x => x.MemberId == memId))
                    {
                        try
                        {
                            duesPaidSheet.Cells[rowReport, 1].Value = attendee.DerbyName;
                            duesNotPaidSheet.Cells[rowReport, 1].Value = attendee.DerbyName;
                            rowReport += 1;
                        }
                        catch (Exception exception)
                        {
                            ErrorDatabaseManager.AddException(exception, exception.GetType());
                        }
                    }
                    rowReport = 2;
                    foreach (var due in duesItem.DuesFees)
                    {
                        duesPaidSheet.Cells[1, column].Value = due.PayBy.ToShortDateString();
                        duesNotPaidSheet.Cells[1, column].Value = due.PayBy.ToShortDateString();
                        foreach (var attendee in duesItem.Members.Where(x => x.MemberId == memId))
                        {
                            if (attendee.DerbyName == "duesMem201312last")
                            { }

                            double paid = due.DuesCollected.Where(x => x.MemberPaidId == attendee.MemberId).Sum(x => x.DuesPaid);
                            var required = due.DuesRequired.Where(x => x.MemberRequiredId == attendee.MemberId).FirstOrDefault();
                            var classification = duesItem.Classifications.Where(x => x.MembersInClass.Where(y => y.MemberId == attendee.MemberId).Count() > 0).FirstOrDefault();

                            double duesDue = 0.0;
                            bool doesNotPayDues = false;
                            if (required != null)
                                duesDue = required.DuesRequire;
                            else if (classification != null)
                            {
                                doesNotPayDues = classification.DoesNotPayDues;
                                duesDue = classification.FeeRequired;
                            }
                            else
                                duesDue = due.CostOfDues;
                            double notPaid = duesDue - paid;
                            duesPaidSheet.Cells[rowReport, column].Value = paid;
                            duesNotPaidSheet.Cells[rowReport, column].Value = notPaid;
                            if (paid == 0)
                            {
                                var waived = due.DuesCollected.Where(x => x.MemberPaidId == attendee.MemberId).FirstOrDefault();
                                if (waived != null && waived.IsWaived)
                                {
                                    duesPaidSheet.Cells[rowReport, column].Value = "W";
                                    duesNotPaidSheet.Cells[rowReport, column].Value = "W";
                                }
                            }

                            rowReport += 1;
                        }
                        duesPaidSheet.Cells[rowReport, column].Formula = "=sum(" + RDN.Utilities.Strings.StringExt.GetExcelColumnName(column) + "2:" + RDN.Utilities.Strings.StringExt.GetExcelColumnName(column) + (rowReport - 1) + ")";
                        duesNotPaidSheet.Cells[rowReport, column].Formula = "=sum(" + RDN.Utilities.Strings.StringExt.GetExcelColumnName(column) + "2:" + RDN.Utilities.Strings.StringExt.GetExcelColumnName(column) + (rowReport - 1) + ")";
                        column += 1;
                        rowReport = 2;
                    }

                    duesPaidSheet.Cells["A1:K20"].AutoFitColumns();
                    duesNotPaidSheet.Cells["A1:K20"].AutoFitColumns();
                }
                catch (Exception exception)
                {
                    ErrorDatabaseManager.AddException(exception, exception.GetType());
                }
                //Generate A File with Random name
                Byte[] bin = p.GetAsByteArray();
                string file = RDN.Utilities.Strings.StringExt.ToExcelFriendly(" Dues Report " + duesItem.LeagueOwnerName) + "_" + DateTime.UtcNow.ToString("yyyymmdd") + ".xlsx";
                return File(bin, RDN.Utilities.IO.FileExt.GetMIMEType(file), file);
            }
        }
        public ActionResult DuesManagementByMember(string type, string id)
        {
            try
            {
                var memId = RDN.Library.Classes.Account.User.GetMemberId();
                NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(Request.Url.Query);
                string updated = nameValueCollection["u"];

                if (!String.IsNullOrEmpty(updated) && updated == SiteMessagesEnum.sww.ToString())
                {
                    SiteMessage message = new SiteMessage();
                    message.MessageType = SiteMessageType.Success;
                    message.Message = "Something went wrong. Error sent to developers, please try again later.";
                    this.AddMessage(message);
                }
                if (!MemberCache.IsMemberApartOfLeague(memId, new Guid(id)))
                    return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.na));

                var league = MemberCache.GetLeagueOfMember(memId);
                if (league != null)
                    SetCulture(league.CultureSelected);

                DuesPortableModel dues = new DuesPortableModel();
                dues.LeagueOwnerId = new Guid(id);
                dues.OwnerEntity = type;
                var dues2 = DuesFactory.GetDuesObject(new Guid(id), memId);
                if (dues2.DuesId != new Guid())
                    dues = dues2;
                return View(dues);
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));

        }
        public ActionResult PayDuesOnlinePayPal(DuesPortableModel duesModel)
        {
            try
            {
                if (!String.IsNullOrEmpty(Request.Form["DuesItemId"]))
                {
                    Guid memberId = RDN.Library.Classes.Account.User.GetMemberId();
                    var mem = MemberCache.GetMemberDisplay(memberId);
                    var dues2 = DuesFactory.GetDuesCollectionItem(Convert.ToInt64(Request.Form["DuesItemId"]), duesModel.DuesId, memberId);
                    if (dues2 != null)
                    {
                        PaymentGateway pg = new PaymentGateway();

                        var f = pg.StartInvoiceWizard()
                            .Initalize(ServerConfig.RDNATION_STORE_ID, dues2.Currency, PaymentProvider.Paypal, SiteSingleton.Instance.IsPayPalLive, ChargeTypeEnum.DuesItem)
                            .SetInvoiceId(Guid.NewGuid())
                            .AddDuesItem(new Library.Classes.Payment.Classes.Invoice.InvoiceDuesItem
                            {
                                BasePrice = (decimal)dues2.DuesFees.FirstOrDefault().TotalPaymentNeededFromMember,
                                WhoPaysFees = dues2.WhoPaysProcessorFeesEnum,
                                DuesId = dues2.DuesId,
                                DuesItemId = dues2.DuesFees.FirstOrDefault().DuesItemId,
                                MemberPaidId = memberId,
                                Name = "Dues For " + dues2.DuesFees.FirstOrDefault().PayBy.ToString("yyyy/MM/dd"),
                                PaidForDate = dues2.DuesFees.FirstOrDefault().PayBy,
                                Description = "Dues Payment",
                            })
                            .SetInvoiceContactData(new Library.Classes.Payment.Classes.Invoice.InvoiceContactInfo
                            {
                                Email = mem.Email,
                                FirstName = mem.Firstname,
                                LastName = mem.LastName,
                                Phone = mem.PhoneNumber,
                            })
                                                .FinalizeInvoice();
                        if (f.Status == InvoiceStatus.Paypal_Email_Not_Confirmed)
                            return Redirect(Url.Content("~/dues/member/" + duesModel.LeagueOwnerId.ToString().Replace("-", "") + "/" + memberId.ToString().Replace("-", "")) + "?u=" + SiteMessagesEnum.ppldnc.ToString());
                        else if (f.Status != InvoiceStatus.Failed)
                            return Redirect(f.RedirectLink);
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, GetType());
            }
            return Redirect(Url.Content("~/dues/league/" + duesModel.LeagueOwnerId.ToString().Replace("-", "")) + "?u=" + SiteMessagesEnum.sww.ToString());
        }
Esempio n. 16
0
 private static void AddTotalWithstandingToMember(DuesPortableModel due, double feeToAdd, MemberDisplayBasic member)
 {
     var memberWhoOwes = due.Members.Where(x => x.MemberId == member.MemberId).FirstOrDefault();
     if (memberWhoOwes != null)
         memberWhoOwes.TotalWithstanding += feeToAdd;
     else
     {
         due.Members.Add(new MemberDisplayDues { MemberId = member.MemberId, DerbyName = member.DerbyName, TotalWithstanding = feeToAdd, UserId = member.UserId });
     }
 }
Esempio n. 17
0
 public static bool UpdateDuesSettings(DuesPortableModel duesObject)
 {
     try
     {
         var dc = new ManagementContext();
         var dues = (from xx in dc.FeeManagement.Include("LeagueOwner")
                     where xx.LeagueOwner.LeagueId == duesObject.LeagueOwnerId
                     select xx).FirstOrDefault();
         dues.CurrencyRate = dc.ExchangeRates.Where(x => x.CurrencyAbbrName == duesObject.Currency).FirstOrDefault();
         dues.DayOfMonthToCollectDefault = duesObject.DayOfMonthToCollectDefault;
         dues.DaysBeforeDeadlineToNotifyDefault = duesObject.DaysBeforeDeadlineToNotifyDefault;
         dues.FeeCostDefault = Convert.ToDouble(duesObject.DuesCostDisplay);
         dues.EmailResponse = duesObject.DuesEmailText;
         dues.AcceptPaymentsOnline = duesObject.AcceptPaymentsOnline;
         if (!String.IsNullOrEmpty(duesObject.PayPalEmailAddress))
             duesObject.PayPalEmailAddress = duesObject.PayPalEmailAddress.Trim();
         dues.PayPalEmailAddress = duesObject.PayPalEmailAddress;
         dues.WhoPaysProcessorFeesEnum = Convert.ToInt32(duesObject.WhoPaysProcessorFeesEnum);
         dues.LockDownManagementToManagersOnly = duesObject.LockDownManagementToManagersOnly;
         dc.SaveChanges();
         MemberCache.ClearLeagueMembersCache(duesObject.LeagueOwnerId);
         MemberCache.ClearLeagueMembersApiCache(duesObject.LeagueOwnerId);
         return true;
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return false;
 }
        public ActionResult EditDuesItem(DuesPortableModel duesItem)
        {
            try
            {
                DateTime dateTime = Convert.ToDateTime(HttpContext.Request.Form["PayBy"]);
                double payBy = Convert.ToDouble(HttpContext.Request.Form["DuesCost"]);
                long duesItemId = Convert.ToInt64(HttpContext.Request.Form["DuesItemId"]);

                DuesFactory.UpdateDuesCollectionItem(duesItemId, duesItem.DuesId, dateTime, payBy);
                var dues = DuesFactory.GetDuesCollectionItem(duesItemId, duesItem.DuesId, RDN.Library.Classes.Account.User.GetMemberId());
                ViewBag.Saved = true;

                return View(dues);
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }
        public static DuesPortableModel PullClassifications(Guid duesManagementId, Guid memId)
        {
            DuesPortableModel fClass = new DuesPortableModel();
            try
            {
                var dc = new ManagementContext();
                var clas = (from xx in dc.FeeManagement.Include("FeeClassifications.MembersClassified").Include("FeeClassifications.MembersClassified.Member")
                            where xx.FeeManagementId == duesManagementId
                            select xx).FirstOrDefault();

                fClass.LeagueOwnerId = clas.LeagueOwner.LeagueId;
                fClass.LeagueOwnerName = clas.LeagueOwner.Name;
                fClass.DuesId = clas.FeeManagementId;
                fClass.OwnerEntity = DuesOwnerEntityEnum.league.ToString();
                fClass.DuesCost = clas.FeeCostDefault;
                var members = MemberCache.GetLeagueMembers(memId, fClass.LeagueOwnerId);
                foreach (var m in members.OrderBy(x => x.DerbyName))
                {
                    MemberDisplayDues mem = new MemberDisplayDues();
                    mem.MemberId = m.MemberId;
                    mem.DerbyName = m.DerbyName;
                    mem.PlayerNumber = m.PlayerNumber;
                    mem.LastName = m.LastName;

                    var classification = clas.FeeClassifications.Where(x => x.MembersClassified.Where(y => y.Member.MemberId == mem.MemberId).Count() > 0).FirstOrDefault();
                    if (classification != null)
                        mem.ClassificationId = classification.FeeClassificationId;

                    fClass.Members.Add(mem);
                }
                foreach (var c in clas.FeeClassifications)
                {
                    FeeClassified fc = new FeeClassified();
                    fc.FeeClassificationId = c.FeeClassificationId;
                    fc.FeeRequired = c.FeeRequired;
                    fc.Name = c.Name;
                    fClass.Classifications.Add(fc);
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return fClass;
        }
Esempio n. 20
0
        public static DuesPortableModel GetDuesCollectionItem(long duesItemId, Guid duesManagementId, Guid currentMemberId)
        {
            try
            {
                DuesPortableModel due = new DuesPortableModel();
                var dc = new ManagementContext();
                var dues = (from xx in dc.FeeItem.Include("FeeManagedBy").Include("FeeManagedBy.FeeClassifications").Include("FeeManagedBy.FeeClassifications").Include("FeeManagedBy.FeeClassifications.MembersClassified").Include("FeeManagedBy.FeeClassifications.MembersClassified.Member")
                            where xx.FeeManagedBy.FeeManagementId == duesManagementId
                            where xx.FeeCollectionId == duesItemId
                            select xx).FirstOrDefault();


                if (dues != null)
                {
                    due.OwnerEntity = DuesOwnerEntityEnum.league.ToString();
                    due.DayOfMonthToCollectDefault = dues.FeeManagedBy.DayOfMonthToCollectDefault;
                    due.DaysBeforeDeadlineToNotifyDefault = dues.FeeManagedBy.DaysBeforeDeadlineToNotifyDefault;
                    due.DuesCostDisplay = dues.FeeManagedBy.FeeCostDefault.ToString("N2");
                    due.DuesCost = dues.FeeManagedBy.FeeCostDefault;
                    due.DuesId = duesManagementId;
                    due.LeagueOwnerId = dues.FeeManagedBy.LeagueOwner.LeagueId;
                    due.LeagueOwnerName = dues.FeeManagedBy.LeagueOwner.Name;
                    due.AcceptPaymentsOnline = dues.FeeManagedBy.AcceptPaymentsOnline;
                    due.PayPalEmailAddress = dues.FeeManagedBy.PayPalEmailAddress;
                    due.EmailResponse = dues.FeeManagedBy.EmailResponse;
                    due.WhoPaysProcessorFeesEnum = (WhoPaysProcessorFeesEnum)Enum.Parse(typeof(WhoPaysProcessorFeesEnum), dues.FeeManagedBy.WhoPaysProcessorFeesEnum.ToString());
                    if (dues.FeeManagedBy.CurrencyRate != null)
                        due.Currency = dues.FeeManagedBy.CurrencyRate.CurrencyAbbrName;
                    else
                        due.Currency = "USD";

                    foreach (var classification in dues.FeeManagedBy.FeeClassifications)
                    {
                        FeeClassified c = new FeeClassified();
                        c.FeeClassificationId = classification.FeeClassificationId;
                        c.FeeRequired = classification.FeeRequired;
                        c.Name = classification.Name;
                        c.DoesNotPayDues = classification.DoesNotPayDues;

                        foreach (var mem in classification.MembersClassified)
                            c.MembersInClass.Add(new MemberDisplayBasic() { DerbyName = mem.Member.DerbyName, MemberId = mem.Member.MemberId });

                        due.Classifications.Add(c);
                    }

                    DuesItem item = new DuesItem();
                    item.CostOfDues = dues.CostOfFee;
                    item.DuesItemId = dues.FeeCollectionId;
                    item.PayBy = dues.PayBy;
                    item.TotalPaid = 0.00;
                    item.TotalWithstanding = 0.00;
                    item.TotalPaymentNeededFromMember = dues.CostOfFee;

                    foreach (var fee in dues.FeesRequired)
                    {
                        DuesRequired col = new DuesRequired();
                        col.DuesRequire = fee.FeeRequired;
                        col.DuesRequiredId = fee.FeeRequiredId;
                        col.IsPaidInFull = fee.IsPaidInFull;
                        col.MemberRequiredId = fee.MemberRequiredFrom.MemberId;
                        col.MemberRequiredName = fee.MemberRequiredFrom.DerbyName;
                        col.Note = fee.Note;
                        col.IsWaived = fee.IsFeeWaived;
                        col.RequiredDate = fee.Created;

                        item.DuesRequired.Add(col);
                    }
                    foreach (var fee in dues.FeesCollected)
                    {
                        DuesCollected col = new DuesCollected();
                        col.DuesPaid = fee.FeeCollected;
                        item.TotalPaid += fee.FeeCollected;
                        col.DuesCollectedId = fee.FeeCollectionId;
                        col.IsPaidInFull = fee.IsPaidInFull;
                        col.MemberPaidId = fee.MemberPaid.MemberId;
                        col.MemberPaidName = fee.MemberPaid.DerbyName;
                        col.Note = fee.Note;
                        col.IsWaived = fee.IsFeeWaived;
                        col.WasDuesClearedByUser = fee.WasClearedByUser;
                        col.PaidDate = fee.Created;
                        if (currentMemberId == fee.MemberPaid.MemberId)
                        {
                            if (col.IsPaidInFull || col.IsWaived)
                                item.IsCurrentMemberPaidOrWaivedInFull = true;
                        }

                        item.DuesCollected.Add(col);
                    }
                    var members = dues.FeeManagedBy.LeagueOwner.Members.Where(x => x.IsInactiveForLeague == false && x.HasLeftLeague == false).OrderBy(x => x.Member.DerbyName).ToList();
                    foreach (var member in members)
                    {
                        //if the member joined after the dues was due.

                        //adds every member to the member list
                        MemberDisplayDues mem = new MemberDisplayDues();
                        mem.MemberId = member.Member.MemberId;
                        mem.DerbyName = member.Member.DerbyName;
                        mem.LastName = member.Member.Lastname;

                        if (member.Member.ContactCard != null && member.Member.ContactCard.Emails.FirstOrDefault() != null)
                            mem.UserId = Guid.NewGuid();
                        else
                            mem.UserId = member.Member.AspNetUserId;

                        var collection = item.DuesCollected.Where(x => x.MemberPaidId == mem.MemberId);
                        var required = item.DuesRequired.Where(x => x.MemberRequiredId == mem.MemberId).FirstOrDefault();
                        var classification = due.Classifications.Where(x => x.MembersInClass.Where(y => y.MemberId == mem.MemberId).Count() > 0).FirstOrDefault();

                        //set variables before defining them below.
                        mem.collected = 0.00;
                        mem.isPaidFull = false;
                        mem.isWaived = false;

                        if (required != null)
                            mem.due = required.DuesRequire;
                        else if (classification != null)
                        {
                            mem.DoesNotPayDues = classification.DoesNotPayDues;
                            mem.isWaived = classification.DoesNotPayDues;
                            mem.due = classification.FeeRequired;
                            if (mem.due <= 0)
                                mem.isPaidFull = true;
                        }
                        else
                            mem.due = item.CostOfDues;


                        foreach (var col in collection)
                        {
                            mem.collected += col.DuesPaid;
                            mem.due -= col.DuesPaid;
                            mem.isPaidFull = col.IsPaidInFull;
                            mem.isWaived = col.IsWaived;
                            mem.DatePaid = col.PaidDate;
                        }
                        bool wasDuesClearedByUser = false;
                        if (collection.Where(x => x.WasDuesClearedByUser == true).FirstOrDefault() != null)
                            wasDuesClearedByUser = true;
                        //waive the user since they were created after dues was due.
                        if (item.PayBy < member.Created && wasDuesClearedByUser == false)
                        {
                            mem.isWaived = true;
                            mem.isPaidFull = true;
                        }
                        mem.tempDue = mem.due;
                        due.Members.Add(mem);
                        //gets member in collection list
                        var collected = item.DuesCollected.Where(x => x.MemberPaidId == member.Member.MemberId);
                        if (collected.Count() == 0)
                        {
                            //if the member was created after payment, we don't require member to pay.
                            if (item.PayBy > member.Created)
                            {
                                item.TotalWithstanding -= mem.due;
                                if (member.Member.MemberId == currentMemberId)
                                {
                                    item.TotalPaidFromMember = 0.00;
                                    item.TotalPaymentNeededFromMember = mem.due;
                                    if (mem.due == 0.0)
                                        item.IsCurrentMemberPaidOrWaivedInFull = true;
                                }
                            }
                        }
                        else
                        {
                            //make sure member joined dues program before dues item is due.
                            if (item.PayBy > member.Created)
                            {
                                //gets the total dues paid by the member for this month.  Can pay in increments so thats
                                // why we check for all collected items.
                                double totalPaid = 0.00;
                                foreach (var c in collected)
                                {
                                    totalPaid += c.DuesPaid;
                                }
                                //if the total dues paid isn't equal to the actual cost of the month,
                                // we subtract it from the total withstanding dues.
                                if (totalPaid != item.CostOfDues)
                                {
                                    item.TotalWithstanding -= totalPaid;
                                }
                                //total withstanding for the current member accessing this page.
                                if (member.Member.MemberId == currentMemberId)
                                {
                                    item.TotalPaymentNeededFromMember = mem.due;
                                    item.TotalPaidFromMember = totalPaid;
                                }
                            }
                        }

                    }
                    due.DuesFees.Add(item);
                }
                return due;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return null;
        }
 public ActionResult CreateDuesManagement(DuesPortableModel dues)
 {
     try
     {
         DuesFactory.CreateDuesObject(dues.LeagueOwnerId, Library.Classes.Dues.Enums.DuesOwnerEntityEnum.league);
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return Redirect(Url.Content("~/dues/" + dues.OwnerEntity + "/" + dues.LeagueOwnerId.ToString().Replace("-", "")));
 }
Esempio n. 22
0
        public static DuesPortableModel GetDuesObject(Guid leagueId, Guid currentMemberId)
        {
            DuesPortableModel due = new DuesPortableModel();
            try
            {
                var dc = new ManagementContext();
                var dues = (from xx in dc.FeeManagement.Include("LeagueOwner").Include("FeeClassifications").Include("FeeClassifications").Include("FeeClassifications.MembersClassified").Include("FeeClassifications.MembersClassified.Member")
                            where xx.LeagueOwner.LeagueId == leagueId
                            select xx).FirstOrDefault();

                if (dues != null)
                {
                    due.OwnerEntity = DuesOwnerEntityEnum.league.ToString();
                    due.DayOfMonthToCollectDefault = dues.DayOfMonthToCollectDefault;
                    due.DaysBeforeDeadlineToNotifyDefault = dues.DaysBeforeDeadlineToNotifyDefault;
                    due.DuesCostDisplay = dues.FeeCostDefault.ToString("N2");
                    due.DuesCost = dues.FeeCostDefault;
                    due.DuesId = dues.FeeManagementId;
                    due.LeagueOwnerId = dues.LeagueOwner.LeagueId;
                    due.LeagueOwnerName = dues.LeagueOwner.Name;
                    due.AcceptPaymentsOnline = dues.AcceptPaymentsOnline;
                    due.PayPalEmailAddress = dues.PayPalEmailAddress;
                    due.WhoPaysProcessorFeesEnum = (WhoPaysProcessorFeesEnum)Enum.Parse(typeof(WhoPaysProcessorFeesEnum), dues.WhoPaysProcessorFeesEnum.ToString());
                    due.DuesEmailText = dues.EmailResponse;

                    foreach (var classification in dues.FeeClassifications)
                    {
                        FeeClassified c = new FeeClassified();
                        c.FeeClassificationId = classification.FeeClassificationId;
                        c.FeeRequired = classification.FeeRequired;
                        c.Name = classification.Name;
                        c.DoesNotPayDues = classification.DoesNotPayDues;

                        foreach (var mem in classification.MembersClassified)
                            c.MembersInClass.Add(new MemberDisplayBasic() { DerbyName = mem.Member.DerbyName, MemberId = mem.Member.MemberId });

                        due.Classifications.Add(c);
                    }

                    var members = dues.LeagueOwner.Members.Where(x => x.IsInactiveForLeague == false && x.HasLeftLeague == false).OrderBy(x => x.Member.DerbyName).ToList();
                    foreach (var member in members)
                    {
                        MemberDisplayDues mem = new MemberDisplayDues();
                        mem.MemberId = member.Member.MemberId;
                        mem.DerbyName = member.Member.DerbyName;
                        mem.JoinedLeague = member.Created;
                        mem.LastName = member.Member.Lastname;
                        if (member.Member.ContactCard != null && member.Member.ContactCard.Emails.FirstOrDefault() != null)
                            mem.UserId = Guid.NewGuid();
                        else
                            mem.UserId = member.Member.AspNetUserId;

                        due.Members.Add(mem);
                    }

                    var duess = dues.Fees.OrderByDescending(x => x.PayBy);
                    foreach (var d in duess)
                    {
                        DuesItem item = new DuesItem();
                        item.CostOfDues = d.CostOfFee;
                        item.DuesItemId = d.FeeCollectionId;
                        item.PayBy = d.PayBy;
                        item.TotalPaid = 0.00;
                        item.TotalWithstanding = 0.00;
                        item.TotalPaymentNeededFromMember = d.CostOfFee;
                        item.ClassificationName = "";
                        item.MemberClassificationName = "";
                        foreach (var fee in d.FeesCollected)
                        {
                            DuesCollected col = new DuesCollected();
                            col.DuesPaid = fee.FeeCollected;
                            item.TotalPaid += fee.FeeCollected;
                            col.DuesCollectedId = fee.FeeCollectionId;
                            col.IsPaidInFull = fee.IsPaidInFull;
                            col.MemberPaidId = fee.MemberPaid.MemberId;
                            col.MemberPaidName = fee.MemberPaid.DerbyName;
                            col.Note = fee.Note;
                            col.IsWaived = fee.IsFeeWaived;
                            if (currentMemberId == fee.MemberPaid.MemberId)
                            {
                                if (col.IsPaidInFull || col.IsWaived)
                                    item.IsCurrentMemberPaidOrWaivedInFull = true;

                            }
                            item.DuesCollected.Add(col);
                        }
                        foreach (var fee in d.FeesRequired)
                        {
                            DuesRequired col = new DuesRequired();
                            col.DuesRequire = fee.FeeRequired;
                            col.DuesRequiredId = fee.FeeRequiredId;
                            col.IsPaidInFull = fee.IsPaidInFull;
                            col.MemberRequiredId = fee.MemberRequiredFrom.MemberId;
                            col.MemberRequiredName = fee.MemberRequiredFrom.DerbyName;
                            col.Note = fee.Note;
                            col.IsWaived = fee.IsFeeWaived;

                            item.DuesRequired.Add(col);
                        }

                        foreach (var member in due.Members)
                        {

                            //gets member in collection list
                            var collected = item.DuesCollected.Where(x => x.MemberPaidId == member.MemberId);
                            var required = item.DuesRequired.Where(x => x.MemberRequiredId == member.MemberId).FirstOrDefault();
                            var classification = due.Classifications.Where(x => x.MembersInClass.Where(y => y.MemberId == member.MemberId).Count() > 0).FirstOrDefault();

                            bool doesNotPayDues = false;
                            double duesDue = 0.0;
                            if (required != null)
                            {
                                duesDue = required.DuesRequire;
                                if (member.MemberId == currentMemberId)
                                {
                                    item.CostOfDuesFromMember = required.DuesRequire;
                                    item.MemberClassificationName = "Custom";
                                }
                            }
                            else if (classification != null)
                            {
                                doesNotPayDues = classification.DoesNotPayDues;
                                duesDue = classification.FeeRequired;
                                //if the user was classified and told they don't have to pay dues.
                                if (doesNotPayDues && duesDue <= 0)
                                {
                                    DuesCollected col = new DuesCollected();
                                    col.MemberPaidId = member.MemberId;
                                    col.IsWaived = true;
                                    if (currentMemberId == member.MemberId)
                                    {
                                        item.IsCurrentMemberPaidOrWaivedInFull = true;

                                    }
                                    item.DuesCollected.Add(col);
                                }

                                item.CostOfDuesFromMember = classification.FeeRequired;
                                //item.MemberClassificationName = classification.Name;
                                member.ClassificationId = classification.FeeClassificationId;
                                member.ClassificationName = classification.Name;
                                if (member.MemberId == currentMemberId)
                                    item.MemberClassificationName = classification.Name;
                            }
                            else
                            {
                                if (member.MemberId == currentMemberId)
                                {
                                    item.CostOfDuesFromMember = item.CostOfDues;
                                    item.MemberClassificationName = "Default";
                                }
                                duesDue = item.CostOfDues;
                            }

                            //no dues were collected
                            if (collected.Count() == 0)
                            {
                                //waive the user since they were created after dues was due.
                                if (item.PayBy < member.JoinedLeague)
                                {
                                    DuesCollected col = new DuesCollected();
                                    col.MemberPaidId = member.MemberId;
                                    col.IsWaived = true;
                                    if (currentMemberId == member.MemberId)
                                    {
                                        item.IsCurrentMemberPaidOrWaivedInFull = true;

                                    }
                                    item.DuesCollected.Add(col);
                                }
                                else
                                {
                                    item.TotalWithstanding -= duesDue;
                                    AddTotalWithstandingToMember(due, duesDue, member);
                                    if (member.MemberId == currentMemberId)
                                    {
                                        item.TotalPaidFromMember = 0.00;
                                        item.TotalPaymentNeededFromMember = duesDue;
                                        item.CostOfDuesFromMember = duesDue;
                                        if (duesDue <= 0)
                                            item.IsCurrentMemberPaidOrWaivedInFull = true;
                                    }
                                }

                            }
                            else
                            {
                                bool isWaived = false;
                                //gets the total dues paid by the member for this month.  Can pay in increments so thats
                                // why we check for all collected items.
                                double totalPaid = 0.00;
                                foreach (var c in collected)
                                {
                                    totalPaid += c.DuesPaid;
                                    isWaived = c.IsWaived;
                                    member.collected += c.DuesPaid;
                                }
                                //waive the user since they were created after dues was due.
                                if (item.PayBy < member.JoinedLeague)
                                    isWaived = true;

                                //if the total dues paid isn't equal to the actual cost of the month,
                                // we subtract it from the total withstanding dues.
                                if (totalPaid != item.CostOfDues && !isWaived)
                                {
                                    item.TotalWithstanding -= (duesDue - totalPaid);

                                    //generating a list of members who all have outstanding balances with the league.
                                    AddTotalWithstandingToMember(due, (duesDue - totalPaid), member);

                                }
                                //total withstanding for the current member accessing this page.
                                if (member.MemberId == currentMemberId)
                                {
                                    item.CostOfDuesFromMember = duesDue;
                                    item.TotalPaymentNeededFromMember = (duesDue - totalPaid);
                                    item.TotalPaidFromMember = totalPaid;
                                    if (item.TotalPaymentNeededFromMember <= 0)
                                        item.IsCurrentMemberPaidOrWaivedInFull = true;
                                }
                            }

                        }
                        due.DuesFees.Add(item);
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return due;
        }