Exemplo n.º 1
0
        public void Save(Model.EDEntities db)
        {
            var result = (from p in db.Certificates
                          where p.SerialNumber == this.SerialNumber
                          select p).Count();

            if (result > 0)
            {
                throw new ApplicationException("Person with this certificate has already been registered");
            }

            var certificate = this.Map();

            db.Certificates.Add(certificate);
            db.SaveChanges();
            this.ID = certificate.ID;
        }
Exemplo n.º 2
0
        public void Save(Model.EDEntities db)
        {
            var result = (from p in db.People
                          where p.Login.ToUpper() == this.Login.ToUpper()
                          select p).Count();

            if (result > 0)
            {
                throw new ApplicationException("Person with this login has already been registered");
            }

            var person = this.Map();

            db.People.Add(person);
            db.SaveChanges();
            this.ID = person.ID;
        }
Exemplo n.º 3
0
        public void Vote()
        {
            using (var db = new Model.EDEntities())
            {
                var result = (from p in db.PetitionVotes
                              where p.PetitionID == this.Petition.ID
                                 && (p.PersonID == this.Person.ID || p.CertificateID == this.Certificate.ID)
                              select p).Count();

                if (result > 0)
                    throw new ApplicationException("This vote was already counted");

                var vote = this.Map();
                db.PetitionVotes.Add(vote);
                db.SaveChanges();
                this.ID = vote.ID;
            }
        }
Exemplo n.º 4
0
        public void Vote()
        {
            using (var db = new Model.EDEntities())
            {
                var result = (from p in db.AgreementVotes
                              where p.AgreementID == this.Agreement.ID &&
                              (p.PersonID == this.Person.ID || p.CertificateID == this.Certificate.ID)
                              select p).Count();

                if (result > 0)
                {
                    throw new ApplicationException("This vote was already counted");
                }

                var vote = this.Map();
                db.AgreementVotes.Add(vote);
                db.SaveChanges();
                this.ID = vote.ID;
            }
        }