Ejemplo n.º 1
0
        /// <summary>
        /// Checks for null entries and puts
        /// </summary>
        public void getDonorNames()
        {
            // populates donor names
            ConvictsContext      db    = new ConvictsContext();
            List <PaymentRecord> found = (from payments in db.Payments
                                          where payments.DonorName == null
                                          select payments).ToList();

            foreach (var payment in found)
            {
                try
                {
                    convictsforacauseWS.CatalystCRMWebservice CFACWS = new convictsforacauseWS.CatalystCRMWebservice();
                    convictsforacauseWS.ContactRecord         CR     = CFACWS.Contact_RetrieveByEmailAddress("*****@*****.**", "convicts2011", 223280, payment.PayerEmail);


                    payment.DonorName = CR.fullName;
                    db.Entry(payment).CurrentValues.SetValues(payment);
                }
                catch (Exception)
                {
                }
            }
            try
            {
                db.SaveChanges();
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses the convict page to get the convict's URL
        /// </summary>
        public void getConvictURLS()
        {
            HtmlWeb      webLoad = new HtmlWeb();
            HtmlDocument doc     = webLoad.Load("http://www.convictsforacause.org.au/support/convict.html");

            var meh = from link in doc.DocumentNode.DescendantNodes()
                      where link.Name == "a" &&
                      link.Attributes["email"] != null
                      select new
            {
                URL   = link.Attributes["href"].Value,
                email = link.Attributes["email"].Value
            };


            // check if team code already exists
            ConvictsContext db    = new ConvictsContext();
            List <Convict>  found = (from convicts in db.Convicts
                                     where convicts.ProfileURL == null
                                     select convicts).ToList();

            foreach (var convict in found)
            {
                foreach (var link in meh)
                {
                    if (convict.Email == link.email)
                    {
                        convict.ProfileURL = link.URL;
                    }
                }

                db.Entry(convict).CurrentValues.SetValues(convict);
            }
            db.SaveChanges();
        }
Ejemplo n.º 3
0
        public void getTeamURLs()
        {
            HtmlWeb      webLoad = new HtmlWeb();
            HtmlDocument doc     = webLoad.Load("http://www.convictsforacause.org.au/support/team.html");

            var meh = from link in doc.DocumentNode.DescendantNodes()
                      where link.Name == "a" &&
                      link.Attributes["teamcode"] != null
                      select new
            {
                URL      = link.Attributes["href"].Value,
                teamcode = link.Attributes["teamcode"].Value
            };


            // check if team code already exists
            ConvictsContext db    = new ConvictsContext();
            List <Team>     found = (from teams in db.Teams
                                     where teams.TeamURL == null
                                     select teams).ToList();

            foreach (var team in found)
            {
                foreach (var link in meh)
                {
                    if (team.TeamCode == link.teamcode)
                    {
                        team.TeamURL = link.URL;
                    }
                }

                db.Entry(team).CurrentValues.SetValues(team);
            }
            db.SaveChanges();
        }
Ejemplo n.º 4
0
        public void CalculateTeamTotals()
        {
            // check if team code already exists
            ConvictsContext db    = new ConvictsContext();
            List <Team>     found = (from teams in db.Teams
                                     select teams).ToList();

            foreach (var team in found)
            {
                try
                {
                    ConvictsContext db1   = new ConvictsContext();
                    var             total = (from payments in db1.Payments
                                             where payments.TeamCode == team.TeamCode
                                             select payments.amount).Sum();

                    team.Total = total.ToString();
                    db.Entry(team).CurrentValues.SetValues(team);
                }
                catch (Exception ex)
                {
                }
            }
            db.SaveChanges();
        }
Ejemplo n.º 5
0
        public void CalculateConvictTotals()
        {
            // check if team code already exists
            ConvictsContext db    = new ConvictsContext();
            List <Convict>  found = (from convicts in db.Convicts
                                     select convicts).ToList();

            foreach (var convict in found)
            {
                try
                {
                    ConvictsContext db1   = new ConvictsContext();
                    var             total = (from payments in db1.Payments
                                             where payments.ConvictEmail == convict.Email
                                             select payments.amount).Sum();

                    convict.Total = total.ToString();
                    db.Entry(convict).CurrentValues.SetValues(convict);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message.ToString());
                }
            }
            db.SaveChanges();
        }
Ejemplo n.º 6
0
        public ConvictReturnObject registerTeamConvict(string email, string name, string registrationType)
        {
            ConvictsContext db = new ConvictsContext();

            Convict convict      = new Convict();
            string  returnStatus = "false";
            string  errorMessage = "";

            try
            {
                Convict found = db.Convicts.Find(email);
                if (found == null)
                {
                    convict.Email        = email;
                    convict.Name         = name;
                    convict.ModifiedDate = DateTime.Now;
                    convict.Total        = "0";
                    convict.CreateDate   = DateTime.Now;
                    convict.TeamType     = registrationType;
                    convict.Total        = "0";
                    convict.TeamCode     = Helper.GenerateTeamCode();
                    convict.ConvictCode  = Helper.GenerateConvictCode();

                    db.Convicts.Add(convict);
                    db.SaveChanges();
                }
                else
                {
                    convict = found;
                    convict.ModifiedDate = DateTime.Now;
                    db.Entry(found).CurrentValues.SetValues(convict);
                    db.SaveChanges();
                }

                returnStatus = "true";
            }
            catch (Exception ex)
            {
                returnStatus = "false";
                errorMessage = ex.Message;
            }


            ConvictReturnObject returnobj = new ConvictReturnObject();

            returnobj.status       = returnStatus;
            returnobj.errorMessage = errorMessage;
            returnobj.convict      = convict;
            return(returnobj);
        }
Ejemplo n.º 7
0
        public static TeamDTO registerTeam(string teamCode, string name, string registrationType)
        {
            ConvictsContext db = new ConvictsContext();

            Team team = new Team();


            string returnStatus = "false";
            string errorMessage = "";

            try
            {
                Team found = db.Teams.Find(teamCode);
                if (found == null)
                {
                    team.TeamCode     = teamCode;
                    team.TeamName     = name;
                    team.TeamType     = registrationType;
                    team.ModifiedDate = DateTime.Now;
                    team.Total        = "0";
                    team.CreateDate   = DateTime.Now;

                    db.Teams.Add(team);
                    db.SaveChanges();
                }
                else
                {
                    team = found;
                    team.ModifiedDate = DateTime.Now;
                    db.Entry(found).CurrentValues.SetValues(team);
                    db.SaveChanges();
                }

                returnStatus = "true";
            }
            catch (Exception ex)
            {
                returnStatus = "false";
                errorMessage = ex.Message;
            }


            TeamDTO returnobj = new TeamDTO();

            returnobj.status       = returnStatus;
            returnobj.errorMessage = errorMessage;
            returnobj.team         = team;
            return(returnobj);
        }
Ejemplo n.º 8
0
        public static ConvictReturnObject registerConvict(string email, string name)
        {
            ConvictsContext db = new ConvictsContext();

            string returnStatus = "false";
            string errorMessage = "";
            Convict convict = new Convict();
            try
            {
                Convict found = db.Convicts.Find(email);
                if (found == null)
                {
                    convict = new Convict();
                    convict.Email = email;
                    convict.Name = name;
                    convict.ModifiedDate = DateTime.Now;
                    convict.Total = "0";
                    convict.CreateDate = DateTime.Now;
                    convict.ConvictCode = Helper.GenerateConvictCode();
                    db.Convicts.Add(convict);
                    db.SaveChanges();
                }
                else
                {
                    convict = found;
                    convict.ModifiedDate = DateTime.Now;
                    db.Entry(found).CurrentValues.SetValues(convict);
                    db.SaveChanges();
                }

                returnStatus = "true";
            }
            catch (Exception ex)
            {
                returnStatus = "false";
                errorMessage = ex.Message;
            }

            ConvictReturnObject returnobj = new ConvictReturnObject();
            returnobj.status = returnStatus;
            returnobj.errorMessage = errorMessage;
            returnobj.convict = convict;

            return returnobj;
        }
Ejemplo n.º 9
0
        public void addTeamCodeToPaymentRecords()
        {
            // check if team code already exists
            ConvictsContext db    = new ConvictsContext();
            List <Convict>  found = (from convicts in db.Convicts
                                     where convicts.TeamCode != null
                                     select convicts).ToList();

            foreach (var convict in found)
            {
                ConvictsContext db1     = new ConvictsContext();
                var             payment = (from payments in db1.Payments
                                           where payments.ConvictEmail == convict.Email
                                           select payments).ToList();

                foreach (var p in payment)
                {
                    p.TeamCode = convict.TeamCode;
                    db1.Entry(p).CurrentValues.SetValues(p);
                }
                db1.SaveChanges();
            }
        }
Ejemplo n.º 10
0
        public static TeamDTO registerTeam(string teamCode, string name, string registrationType)
        {
            ConvictsContext db = new ConvictsContext();

            Team team = new Team();

            string returnStatus = "false";
            string errorMessage = "";

            try
            {
                Team found = db.Teams.Find(teamCode);
                if (found == null)
                {
                    team.TeamCode = teamCode;
                    team.TeamName = name;
                    team.TeamType = registrationType;
                    team.ModifiedDate = DateTime.Now;
                    team.Total = "0";
                    team.CreateDate = DateTime.Now;

                    db.Teams.Add(team);
                    db.SaveChanges();
                }
                else
                {
                    team = found;
                    team.ModifiedDate = DateTime.Now;
                    db.Entry(found).CurrentValues.SetValues(team);
                    db.SaveChanges();
                }

                returnStatus = "true";
            }
            catch (Exception ex)
            {
                returnStatus = "false";
                errorMessage = ex.Message;
            }

            TeamDTO returnobj = new TeamDTO();
            returnobj.status = returnStatus;
            returnobj.errorMessage = errorMessage;
            returnobj.team  = team ;
            return returnobj;
        }
Ejemplo n.º 11
0
        public void getTeamURLs()
        {
            HtmlWeb webLoad = new HtmlWeb();
            HtmlDocument doc = webLoad.Load("http://www.convictsforacause.org.au/support/team.html");

            var meh = from link in doc.DocumentNode.DescendantNodes()
                      where link.Name == "a" &&
                      link.Attributes["teamcode"] != null
                      select new
                      {
                          URL = link.Attributes["href"].Value,
                          teamcode = link.Attributes["teamcode"].Value
                      };

            // check if team code already exists
            ConvictsContext db = new ConvictsContext();
            List<Team> found = (from teams in db.Teams
                                   where teams.TeamURL == null
                                   select teams).ToList();

            foreach (var team in found)
            {
                foreach (var link in meh)
                {
                    if (team.TeamCode == link.teamcode)
                    {
                        team.TeamURL = link.URL;
                    }
                }

                db.Entry(team).CurrentValues.SetValues(team);

            }
            db.SaveChanges();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Checks for null entries and puts 
        /// </summary>
        public void getDonorNames()
        {
            // populates donor names
            ConvictsContext db = new ConvictsContext();
            List<PaymentRecord> found = (from payments in db.Payments
                                         where payments.DonorName == null
                                   select payments).ToList();

            foreach (var payment in found)
            {
                try
                {
                    convictsforacauseWS.CatalystCRMWebservice CFACWS = new convictsforacauseWS.CatalystCRMWebservice();
                    convictsforacauseWS.ContactRecord CR = CFACWS.Contact_RetrieveByEmailAddress("*****@*****.**", "convicts2011", 223280, payment.PayerEmail);

                    payment.DonorName = CR.fullName;
                    db.Entry(payment).CurrentValues.SetValues(payment);

                }
                catch (Exception)
                {

                }

            }
            try
            {
                  db.SaveChanges();
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Parses the convict page to get the convict's URL
        /// </summary>
        public void getConvictURLS()
        {
            HtmlWeb webLoad = new HtmlWeb();
            HtmlDocument doc = webLoad.Load("http://www.convictsforacause.org.au/support/convict.html");

            var meh = from link in doc.DocumentNode.DescendantNodes()
                      where link.Name == "a" &&
                      link.Attributes["email"] != null
                      select new
                      {
                          URL = link.Attributes["href"].Value,
                          email = link.Attributes["email"].Value
                      };

            // check if team code already exists
            ConvictsContext db = new ConvictsContext();
            List<Convict> found = (from convicts in db.Convicts
                                   where convicts.ProfileURL == null
                                   select convicts).ToList();

            foreach (var convict in found)
            {
                foreach(var link in meh )
                {
                    if (convict.Email == link.email)
                    {
                        convict.ProfileURL = link.URL;
                    }
                }

                db.Entry(convict).CurrentValues.SetValues(convict);

            }
            db.SaveChanges();
        }
Ejemplo n.º 14
0
        public void CalculateTeamTotals()
        {
            // check if team code already exists
            ConvictsContext db = new ConvictsContext();
            List<Team> found = (from teams in db.Teams
                        select teams).ToList();

            foreach (var team in found)
            {
                try
                {
                    ConvictsContext db1 = new ConvictsContext();
                    var total = (from payments in db1.Payments
                                 where payments.TeamCode == team.TeamCode
                                 select payments.amount).Sum();

                    team.Total = total.ToString();
                    db.Entry(team).CurrentValues.SetValues(team);
                }
                catch (Exception ex)
                {

                }

            }
            db.SaveChanges();
        }
Ejemplo n.º 15
0
        public void CalculateConvictTotals()
        {
            // check if team code already exists
            ConvictsContext db = new ConvictsContext();
            List<Convict> found = (from convicts in db.Convicts
                        select convicts).ToList();

            foreach (var convict in found)
            {
                try
                {
                    ConvictsContext db1 = new ConvictsContext();
                    var total = (from payments in db1.Payments
                                 where payments.ConvictEmail == convict.Email
                                 select payments.amount).Sum();

                    convict.Total = total.ToString();
                    db.Entry(convict).CurrentValues.SetValues(convict);

                }
                catch (Exception ex)
                {

                    Console.Write(ex.Message.ToString());
                }

            }
            db.SaveChanges();
        }
Ejemplo n.º 16
0
        public void addTeamCodeToPaymentRecords()
        {
            // check if team code already exists
            ConvictsContext db = new ConvictsContext();
            List<Convict> found = (from convicts in db.Convicts
                                   where convicts.TeamCode != null
                                select convicts).ToList();

            foreach (var convict in found)
            {

                ConvictsContext db1 = new ConvictsContext();
                var payment = (from payments in db1.Payments
                              where payments.ConvictEmail  == convict.Email
                              select payments).ToList();

                             foreach (var p in payment)
                             {
                                 p.TeamCode = convict.TeamCode;
                                 db1.Entry(p).CurrentValues.SetValues(p);
                             }
                db1.SaveChanges();
            }
        }