Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
0
 internal static void DeleteContact(Contact contact)
 {
     try
     {
         using (CoreModel db = new CoreModel())
         {
             contact.IsDeleted       = true;
             db.Entry(contact).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         LogHelper.LogError(string.Format("Couldn't delete contact"), ex, 0);
     }
 }
Ejemplo n.º 7
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.º 8
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();
            }
        }
Ejemplo n.º 9
0
        internal static void SaveContact(Contact contact, int clubId)
        {
            try
            {
                using (CoreModel db = new CoreModel())
                {
                    if (contact.Id <= 0)
                    {
                        db.Contact.Add(contact);
                    }
                    else
                    {
                        db.Entry(contact).State = System.Data.Entity.EntityState.Modified;
                    }

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogError(string.Format("Couldn't save contact"), ex, clubId);
            }
        }