public void AddPlan(int QntPlans)
        {
            QoalaEntities qe = new QoalaEntities();

            qe.Entry(this).State = EntityState.Modified;
            qe.SaveChanges();

            Plan p = qe.PLANS.Find(ID_PLAN);

            p.LEFT            = p.LEFT - QntPlans;
            qe.Entry(p).State = EntityState.Modified;
            qe.SaveChanges();
        }
Exemple #2
0
        public void Update(QoalaEntities db)
        {
            var info = findByKey(db, this.KEY);

            info.VALUE = this.VALUE;
            db.SaveChanges();
        }
        // this may should be on ACCESSCONTROL class
        public AccessControl doLogin(QoalaEntities context)
        {
            User user = findByEmail(context, EMAIL);

            if (user != null && user.PASSWORD.Equals(PASSWORD))
            {
                AccessControl access = null;
                //ja teve sessões, busca uma ativa
                if (user.ACCESSCONTROLs.Count() > 0)
                {
                    // melhoria: Adicionar Client ID. e cada tipo de aplicação deverá passar um ClientID para o login, e filtrar aqui.
                    access = user.ACCESSCONTROLs.FirstOrDefault(ac => ac.EXPIRED_AT >= DateTime.Now);
                }

                if (access == null)
                {
                    access = new AccessControl {
                        USER = user
                    };
                    access.Add(context);
                    context.SaveChanges();
                }
                return(access);
            }
            return(null);
        }
Exemple #4
0
 public void UserAdd()
 {
     using (var qe = new QoalaEntities())
     {
         //USER.findByEmail(qe, "email").Delete(qe);
         //qe.SaveChanges();
         User u = new User {
             NAME = "teste", EMAIL = "email", PASSWORD = "******"
         };
         u.Add(qe);
         qe.SaveChanges();
         //Assert.AreNotEqual(0m, u.ID_USER, "Usuario nao foi criado");
         u.Delete(qe);
         qe.SaveChanges();
     }
 }
 public void Update()
 {
     using (QoalaEntities qe = new QoalaEntities())
     {
         qe.Entry(this).State = System.Data.Entity.EntityState.Modified;
         qe.SaveChanges();
     }
 }
 public void Add()
 {
     using (QoalaEntities qe = new QoalaEntities())
     {
         this.CREATED_AT = DateTime.Now;
         this.TOTAL      = LEFT;
         qe.PLANS.Add(this);
         qe.SaveChanges();
     }
 }
 public bool Delete(QoalaEntities context)
 {
     this.Logger().Debug("delete ACCESSCONTROL(" + TOKEN + ") for user: " + this.USER.ToString());
     // Do not remove this entity, just update with expired now
     //context.ACCESSCONTROLs.Remove(this);
     this.EXPIRED_AT           = DateTime.Now;
     context.Entry(this).State = EntityState.Modified;
     context.SaveChanges();
     return(find(context, TOKEN) == null);
 }
 public AccessControl Add(QoalaEntities context)
 {
     this.Logger().Debug("add ACCESSCONTROL for user: "******"-" + USER.ID_USER.ToString();
     // TODO: make the number to addDays configured by USER configuration ou SYSTEM configuration
     EXPIRED_AT = DateTime.Now.AddDays(7);
     CREATED_AT = DateTime.Now;
     context.ACCESSCONTROLs.Add(this);
     context.SaveChanges();
     return(this);
 }
Exemple #9
0
 public void UserHasBeenTaken()
 {
     using (var qe = new QoalaEntities())
     {
         var  email = "abc@abc2";
         User u     = new User {
             NAME = "teste", EMAIL = email, PASSWORD = "******"
         };
         u.Add(qe);
         qe.SaveChanges();
         Assert.IsTrue(User.emailAlreadyExist(qe, email));
     }
 }
Exemple #10
0
 public void UserDelete()
 {
     using (var qe = new QoalaEntities())
     {
         User u = User.findByEmail(qe, "email");
         if (u != null)
         {
             u.Delete(qe);
             qe.SaveChanges();
             Assert.AreEqual(0, qe.USERS.Count(a => a.ID_USER == u.ID_USER));
         }
     }
 }
Exemple #11
0
 public void UserUpdate()
 {
     using (var qe = new QoalaEntities())
     {
         User u = User.findByEmail(qe, "email");
         if (u != null)
         {
             u.NAME = "Teste Atualizado";
             var ret = u.Update(qe);
             qe.SaveChanges();
             Assert.AreNotEqual(0, u.ID_USER);
         }
     }
 }
Exemple #12
0
 public void UserDeletedWithSameEmailNotHasTaken()
 {
     using (var qe = new QoalaEntities())
     {
         var  email = "abcc@abcc";
         User u     = new User {
             NAME = "teste", EMAIL = email, PASSWORD = "******"
         };
         u.Add(qe);
         qe.SaveChanges();
         u.DELETED_AT = DateTime.Now;
         u.Update(qe);
         Assert.IsFalse(User.emailAlreadyExist(qe, email));
     }
 }
Exemple #13
0
 public void Delete(QoalaEntities db)
 {
     db.INFOCOMPANies.Remove(this);
     db.SaveChanges();
 }
Exemple #14
0
 public void Add(QoalaEntities db)
 {
     db.INFOCOMPANies.Add(this);
     db.SaveChanges();
 }