Beispiel #1
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);
        }
Beispiel #2
0
        public string getConvictDetails(string convictCode)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            string  strJSON         = "";
            Convict foundConvict    = Helper.getConvictDetails(convictCode);

            if (foundConvict == null)
            {
                strJSON = js.Serialize("{'name':''}");
            }
            else
            {
                strJSON = js.Serialize("{'name':'" + foundConvict.Name + "', 'emailaddress': '" + foundConvict.Email + "'}");
            }
            return(strJSON);
        }
Beispiel #3
0
        public string getConvictCode(string email)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            string  strJSON         = "";
            Convict found           = db.Convicts.Find(email);

            if (found == null)
            {
                strJSON = js.Serialize("{'convictcode':'0', 'emailaddress': '" + email + "'}");
            }
            else
            {
                strJSON = js.Serialize("{'convictcode':'" + found.ConvictCode + "', 'emailaddress': '" + found.Email + "'}");
            }

            return(strJSON);
        }
Beispiel #4
0
        public string getTeamDetails(string teamCode)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            string  strJSON         = "";
            Team    foundTeam       = Helper.getTeamDetails(teamCode);
            Convict foundConvict    = Helper.getConvictsInTeam(teamCode);

            if (foundTeam == null)
            {
                strJSON = js.Serialize("{'teamcode':'0', 'teamCode': '" + teamCode + "'}");
            }
            else
            {
                strJSON = js.Serialize("{'teamcode':'" + foundTeam.TeamCode + "', 'teamName': '" + foundTeam.TeamName + "', 'emailaddress': '" + foundConvict.Email + "'}");
            }
            return(strJSON);
        }
        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;
        }
        public static bool doesAccountExist(string email)
        {
            ConvictsContext db = new ConvictsContext();
            bool doesAccountExist = false;
            string errorMessage = "";
            Convict convict = new Convict();
            try
            {
                Convict found = db.Convicts.Find(email);
                if (found != null)
                {
                    doesAccountExist = true;
                }
            }
            catch (Exception ex)
            {
                doesAccountExist = false;
                errorMessage = ex.Message;
            }

            return doesAccountExist;
        }
Beispiel #7
0
        public static bool doesAccountExist(string email)
        {
            ConvictsContext db = new ConvictsContext();
            bool            doesAccountExist = false;
            string          errorMessage     = "";
            Convict         convict          = new Convict();

            try
            {
                Convict found = db.Convicts.Find(email);
                if (found != null)
                {
                    doesAccountExist = true;
                }
            }
            catch (Exception ex)
            {
                doesAccountExist = false;
                errorMessage     = ex.Message;
            }

            return(doesAccountExist);
        }
Beispiel #8
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'}";
        }