Exemple #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;
        }
Exemple #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;
        }
        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;
            }
        }
        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;
            }
        }