예제 #1
0
        // update if scoring is complete
        public static void UpdateProposal(Proposal proposal)
        {
            ARCCproposalsDbContext db = new ARCCproposalsDbContext();

            db.Entry(proposal).State = EntityState.Modified;
            db.SaveChanges();
        }
예제 #2
0
        public static void UpdateScore(Score score)
        {
            ARCCproposalsDbContext db = new ARCCproposalsDbContext();

            db.Entry(score).State = EntityState.Modified;
            db.SaveChanges();
        }
예제 #3
0
        public static Proposal GetProposal(int?id)
        {
            ARCCproposalsDbContext db = new ARCCproposalsDbContext();
            Proposal proposal         = new Proposal();

            proposal = db.proposals.Find(id);
            return(proposal);
        }
예제 #4
0
        public static Criteria GetCriteria(int?id)
        {
            ARCCproposalsDbContext db = new ARCCproposalsDbContext();
            var crit = db.criterias.Find(id);

            //crit.ratingsSugg = crit.ratingsSugg.Replace("~", "\n");
            return(crit);
        }
예제 #5
0
        public static int GetUserId(string email)
        {
            ARCCproposalsDbContext db    = new ARCCproposalsDbContext();
            List <User>            users = new List <User>();

            users = db.Users.ToList();
            foreach (User user in users)
            {
                if (user.email == email)
                {
                    return(user.Id);
                }
            }
            return(0);
        }
예제 #6
0
        public static List <Score> GetProposalScores(int?propId)
        {
            ARCCproposalsDbContext db        = new ARCCproposalsDbContext();
            List <Score>           allScores = new List <Score>();
            List <Score>           scorz     = new List <Score>();

            //int numScrz = 0;
            allScores = db.scores.ToList();
            foreach (Score s in allScores)
            {
                if (s.proposalId == propId)
                {
                    //numScrz++;
                    scorz.Add(s);
                }
            }
            //Debug.Write("Number of scores in results: " + scorz.Count);
            return(scorz);
        }
예제 #7
0
        // return a list of all existing ids for populating main list
        public static List <int> GetProposalIds()
        {
            ARCCproposalsDbContext db = new ARCCproposalsDbContext();
            var        props          = db.proposals.ToList();
            List <int> propIds        = new List <int>();

            if (props == null)
            {
                Debug.Write("proposals is empty");
            }
            else
            {
                foreach (Proposal p in props)
                {
                    propIds.Add(p.Id);
                }
            }

            return(propIds);
        }
예제 #8
0
        public static bool CreateUser(User user)
        {
            ARCCproposalsDbContext db    = new ARCCproposalsDbContext();
            List <User>            users = new List <User>();

            users = db.Users.ToList();
            bool userExists = false;

            foreach (User u in users)
            {
                if (user.email == u.email)
                {
                    userExists = true;
                }
            }
            if (!userExists)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
예제 #9
0
        public static void Dispose()
        {
            ARCCproposalsDbContext db = new ARCCproposalsDbContext();

            db.Dispose();
        }