示例#1
0
        public static string getAllDonations()
        {
            string returnStr = "{'status':'true'";

            returnStr += ", 'messages': [ ";

            ConvictsContext db = new ConvictsContext();

            var found = from payments in db.Payments
                        join convicts in db.Convicts on payments.ConvictEmail equals convicts.Email
                        orderby payments.CreateDate descending
                        select new
            {
                Payments = payments,
                Convicts = convicts
            };

            if (found.Count() == 0)
            {
                returnStr = "{'status':'false'}";
            }
            else
            {
                int i = 0;
                foreach (var p in found)
                {
                    if (string.IsNullOrEmpty(p.Payments.DonorName))
                    {
                        continue;
                    }

                    if (p.Payments.Anonymous)
                    {
                        p.Payments.DonorName = "Anonymous";
                    }

                    i++;
                    DonationMessage d = new DonationMessage();
                    d.date = "" + p.Payments.CreateDate.ToShortDateString() + " " + p.Payments.CreateDate.ToShortTimeString();

                    if (p.Payments.PaymentType == "convict donation" || p.Payments.PaymentType == "cash donation")
                    {
                        d.message = p.Payments.DonorName + " posted $" + p.Payments.amount + " bail to " + p.Convicts.Name + "";

                        returnStr += "{'date': '" + d.date + "','url': '" + p.Convicts.ProfileURL + "','message': '" + d.message + "'},";
                    }
                    if (p.Payments.PaymentType == "team donation")
                    {
                        Team t = Helper.getTeamDetails(p.Convicts.TeamCode);
                        if (t != null)
                        {
                            d.message = p.Payments.DonorName + " posted a $" + p.Payments.amount + " bail to team " + t.TeamName;

                            returnStr += "{'date': '" + d.date + "','url': '" + t.TeamURL + "','message': '" + d.message + "'},";
                        }
                    }
                    else if (p.Payments.PaymentType == "team member registration" || p.Payments.PaymentType == "convict registration" || p.Payments.PaymentType == "team registration")
                    {
                        d.message = p.Convicts.Name + " has been jailed and fined $" + p.Payments.amount;

                        returnStr += "{'date': '" + d.date + "','url': '" + p.Convicts.ProfileURL + "','message': '" + d.message + "'},";
                    }
                    else if (p.Payments.PaymentType == "general donation")
                    {
                        d.message = p.Payments.DonorName + " posted $" + p.Payments.amount + " towards " + p.Convicts.Name + " bail.";

                        returnStr += "{'date': '" + d.date + "','url': '" + p.Convicts.ProfileURL + "','message': '" + d.message + "'},";
                    }
                    if (i == 10)
                    {
                        break;
                    }
                }

                returnStr += "]";
                returnStr += "}";
                return(returnStr);
            }
            return("{'status':'false'}");
        }
        public static string getTeamDonations(string teamCode)
        {
            string returnStr = "{'status':'true'";

            returnStr += ", 'messages': [ ";

            ConvictsContext db = new ConvictsContext();

            var found = from payments in db.Payments
                        where teamCode.Contains(payments.TeamCode)
                        orderby payments.CreateDate descending
                        select payments;

            if (found.Count() == 0)
            {
                returnStr = "{'status':'false'}";
                return returnStr;
            }
            else
            {

                foreach (var p in found)
                {
                    if (string.IsNullOrEmpty(p.DonorName))
                        continue;

                    if (p.Anonymous)
                        p.DonorName = "Anonymous";

                    DonationMessage d = new DonationMessage();
                    d.date = "" + p.CreateDate.ToShortDateString() + " " + p.CreateDate.ToShortTimeString();

                    if (p.PaymentType == "convict donation" || p.PaymentType == "cash donation")
                    {
                        Convict foundConvict = Helper.getConvictDetailsByEmail(p.ConvictEmail);
                        d.message = p.DonorName + " posted a $" + p.amount + " bail: " + p.Message;

                        returnStr += "{'date': '" + d.date + "','message': '" + d.message + "'},";
                    }
                    else if (p.PaymentType == "team donation")
                    {
                        Convict foundConvict = Helper.getConvictDetailsByEmail(p.ConvictEmail);
                        d.message = p.DonorName + " posted a $" + p.amount + " bail: " + p.Message;

                        returnStr += "{'date': '" + d.date + "','message': '" + d.message + "'},";
                    }
                    else if (p.PaymentType == "team registration" || p.PaymentType == "convict registration" || p.PaymentType == "team member registration")
                    {
                        Convict foundConvict = Helper.getConvictDetailsByEmail(p.ConvictEmail);
                        d.message = foundConvict.Name + " has been jailed and fined $" + p.amount;

                        returnStr += "{'date': '" + d.date + "','message': '" + d.message + "'},";
                    }
                    else if (p.PaymentType == "general donation")
                    {
                        d.message = p.DonorName + " posted a $" + p.amount + " bail.";

                        returnStr += "{'date': '" + d.date + "','message': '" + d.message + "'},";
                    }

                }

                returnStr += "]";
                returnStr += "}";
                return returnStr;
            }
            //return "{'status':'false'}";
        }
示例#3
0
        public static string getTeamDonations(string teamCode)
        {
            string returnStr = "{'status':'true'";

            returnStr += ", 'messages': [ ";

            ConvictsContext db = new ConvictsContext();

            var found = from payments in db.Payments
                        where teamCode.Contains(payments.TeamCode)
                        orderby payments.CreateDate descending
                        select payments;

            if (found.Count() == 0)
            {
                returnStr = "{'status':'false'}";
                return(returnStr);
            }
            else
            {
                foreach (var p in found)
                {
                    if (string.IsNullOrEmpty(p.DonorName))
                    {
                        continue;
                    }

                    if (p.Anonymous)
                    {
                        p.DonorName = "Anonymous";
                    }

                    DonationMessage d = new DonationMessage();
                    d.date = "" + p.CreateDate.ToShortDateString() + " " + p.CreateDate.ToShortTimeString();

                    if (p.PaymentType == "convict donation" || p.PaymentType == "cash donation")
                    {
                        Convict foundConvict = Helper.getConvictDetailsByEmail(p.ConvictEmail);
                        d.message = p.DonorName + " posted a $" + p.amount + " bail: " + p.Message;

                        returnStr += "{'date': '" + d.date + "','message': '" + d.message + "'},";
                    }
                    else if (p.PaymentType == "team donation")
                    {
                        Convict foundConvict = Helper.getConvictDetailsByEmail(p.ConvictEmail);
                        d.message = p.DonorName + " posted a $" + p.amount + " bail: " + p.Message;

                        returnStr += "{'date': '" + d.date + "','message': '" + d.message + "'},";
                    }
                    else if (p.PaymentType == "team registration" || p.PaymentType == "convict registration" || p.PaymentType == "team member registration")
                    {
                        Convict foundConvict = Helper.getConvictDetailsByEmail(p.ConvictEmail);
                        d.message = foundConvict.Name + " has been jailed and fined $" + p.amount;

                        returnStr += "{'date': '" + d.date + "','message': '" + d.message + "'},";
                    }
                    else if (p.PaymentType == "general donation")
                    {
                        d.message = p.DonorName + " posted a $" + p.amount + " bail.";

                        returnStr += "{'date': '" + d.date + "','message': '" + d.message + "'},";
                    }
                }

                returnStr += "]";
                returnStr += "}";
                return(returnStr);
            }
            //return "{'status':'false'}";
        }
        public static string getAllDonations()
        {
            string returnStr = "{'status':'true'";

            returnStr += ", 'messages': [ ";

            ConvictsContext db = new ConvictsContext();

            var found = from payments in db.Payments
                        join convicts in db.Convicts on payments.ConvictEmail equals convicts.Email
                        orderby payments.CreateDate descending
                        select new
                        {
                            Payments = payments,
                            Convicts = convicts
                        };

            if (found.Count() == 0)
            {
                returnStr = "{'status':'false'}";

            }
            else
            {

                int i = 0;
                foreach (var p in found)
                {
                    if (string.IsNullOrEmpty(p.Payments.DonorName))
                        continue;

                    if (p.Payments.Anonymous)
                        p.Payments.DonorName = "Anonymous";

                    i++;
                    DonationMessage d = new DonationMessage();
                    d.date = "" + p.Payments.CreateDate.ToShortDateString() + " " + p.Payments.CreateDate.ToShortTimeString();

                    if (p.Payments.PaymentType == "convict donation" || p.Payments.PaymentType == "cash donation")
                    {
                        d.message = p.Payments.DonorName + " posted $" + p.Payments.amount + " bail to " + p.Convicts.Name + "";

                        returnStr += "{'date': '" + d.date + "','url': '" + p.Convicts.ProfileURL + "','message': '" + d.message + "'},";
                    }
                    if (p.Payments.PaymentType == "team donation")
                    {
                        Team t = Helper.getTeamDetails(p.Convicts.TeamCode);
                        if (t != null)
                        {
                        d.message = p.Payments.DonorName + " posted a $" + p.Payments.amount + " bail to team " + t.TeamName;

                        returnStr += "{'date': '" + d.date + "','url': '" + t.TeamURL + "','message': '" + d.message + "'},";
                        }
                    }
                    else if (p.Payments.PaymentType == "team member registration" || p.Payments.PaymentType == "convict registration" || p.Payments.PaymentType == "team registration")
                    {
                        d.message = p.Convicts.Name + " has been jailed and fined $" + p.Payments.amount;

                        returnStr += "{'date': '" + d.date + "','url': '" + p.Convicts.ProfileURL + "','message': '" + d.message + "'},";
                    }
                    else if (p.Payments.PaymentType == "general donation")
                    {
                        d.message = p.Payments.DonorName + " posted $" + p.Payments.amount + " towards " + p.Convicts.Name + " bail.";

                        returnStr += "{'date': '" + d.date + "','url': '" + p.Convicts.ProfileURL + "','message': '" + d.message + "'},";
                    }
                    if (i == 10)
                    {
                        break;
                    }

                }

                returnStr += "]";
                returnStr += "}";
                return returnStr;
            }
            return "{'status':'false'}";
        }