Ejemplo n.º 1
0
 internal static void SaveClub(Club club)
 {
     using (CoreModel coreDAL = new CoreModel())
     {
         coreDAL.Entry(club).State = System.Data.Entity.EntityState.Modified;
         coreDAL.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 internal static void SaveGenericFile(GenericFile file)
 {
     using (CoreModel coreDAL = new CoreModel())
     {
         coreDAL.GenericFile.Add(file);
         coreDAL.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 internal static void UpdateGenericFile(GenericFile file)
 {
     using (CoreModel coreDAL = new CoreModel())
     {
         coreDAL.Entry(file).State = System.Data.Entity.EntityState.Modified;
         coreDAL.SaveChanges();
     }
 }
Ejemplo n.º 4
0
        internal static Account SaveAccount(Account acc)
        {
            using (CoreModel coreDAL = new CoreModel())
            {
                if (acc.ID > 0)
                {
                    Account account = coreDAL.Account.Include("Club").Include("AccountAccess").Include("Account_Information")
                                      .Where(a => a.ID == acc.ID).FirstOrDefault();
                    account.AccountAccess.ToList().ForEach(a => a.Accessright.Accessright_Right.ToList());
                    if (account != null)
                    {
                        account.FirstName = acc.FirstName;
                        account.LastName  = acc.LastName;
                        account.UserName  = acc.UserName;
                        account.Image     = acc.Image;
                        account.Gender    = acc.Gender;

                        account.Account_Information.ToList().ForEach(a => coreDAL.Entry(a).State = System.Data.Entity.EntityState.Deleted);
                        acc.Account_Information.ToList().ForEach(a => account.Account_Information.Add(a));

                        account.AccountAccess.ToList().ForEach(a => coreDAL.Entry(a).State = System.Data.Entity.EntityState.Deleted);
                        acc.AccountAccess.ToList().ForEach(a => account.AccountAccess.Add(a));

                        if (!string.IsNullOrEmpty(acc.Password))
                        {
                            account.Password = Sha256Helper.GetHashSha256(acc.Password);
                        }
                        coreDAL.SaveChanges();

                        return(account);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    acc.Password = Sha256Helper.GetHashSha256(acc.Password);
                    coreDAL.Account.Add(acc);
                    coreDAL.SaveChanges();
                    return(acc);
                }
            }
        }
Ejemplo n.º 5
0
 internal static void DeleteUser(int userId, int clubId)
 {
     using (CoreModel coreDAL = new CoreModel())
     {
         Account acc = coreDAL.Account.FirstOrDefault(a => a.ID == userId && a.ClubId == clubId);
         coreDAL.Entry(acc).State = System.Data.Entity.EntityState.Deleted;
         coreDAL.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 internal static void Logout(string token)
 {
     using (CoreModel coreDAL = new CoreModel())
     {
         Account_Session session = coreDAL.Account_Session.FirstOrDefault(a => a.Token == token);
         coreDAL.Entry(session).State = System.Data.Entity.EntityState.Deleted;
         coreDAL.SaveChanges();
     }
 }
Ejemplo n.º 7
0
        internal static void DeleteAccountGenericValues(int userId)
        {
            using (CoreModel coreDAL = new CoreModel())
            {
                var items = coreDAL.Account_Information_Generic_Value.Where(a => a.AccountId == userId).ToList();
                foreach (var item in items)
                {
                    coreDAL.Account_Information_Generic_Value.Remove(item);
                }

                coreDAL.SaveChanges();
            }
        }
Ejemplo n.º 8
0
        internal static void AddToLoginLog(Account acc)
        {
            using (CoreModel coreDAL = new CoreModel())
            {
                LoginLog log = new LoginLog()
                {
                    ClubId = acc.ClubId,
                    UserId = acc.ID,
                    Date   = DateTime.Now
                };

                coreDAL.LoginLog.Add(log);
                coreDAL.SaveChanges();
            }
        }
Ejemplo n.º 9
0
        internal static void AddSession(AccountSessionEntity session)
        {
            using (CoreModel coreDAL = new CoreModel())
            {
                Account_Session sess = new Account_Session()
                {
                    AccountId      = session.AccountId,
                    Token          = session.Token,
                    ExpirationDate = session.ExpirationDate,
                    LoginDate      = DateTime.Now
                };

                coreDAL.Account_Session.Add(sess);
                coreDAL.SaveChanges();
            }
        }
Ejemplo n.º 10
0
 internal static void SaveGenericValues(List <Account_Information_Generic_Value> genericValues)
 {
     using (CoreModel coreDAL = new CoreModel())
     {
         foreach (var item in genericValues)
         {
             if (item.Id > 0)
             {
                 coreDAL.Entry(item).State = System.Data.Entity.EntityState.Modified;
             }
             else
             {
                 coreDAL.Account_Information_Generic_Value.Add(item);
             }
         }
         coreDAL.SaveChanges();
     }
 }
Ejemplo n.º 11
0
        internal static void SaveAccessright(Accessright accessright)
        {
            using (CoreModel coreDAL = new CoreModel())
            {
                if (accessright.ID > 0)
                {
                    var ar = coreDAL.Accessright.Include("Accessright_Right").FirstOrDefault(a => a.ID == accessright.ID);

                    ar.Description = accessright.Description;
                    ar.Name        = accessright.Name;

                    ar.Accessright_Right.ToList().ForEach(a => coreDAL.Entry(a).State = System.Data.Entity.EntityState.Deleted);
                    accessright.Accessright_Right.ToList().ForEach(a => ar.Accessright_Right.Add(a));
                }
                else
                {
                    coreDAL.Accessright.Add(accessright);
                }

                coreDAL.SaveChanges();
            }
        }