Exemplo n.º 1
0
        public bool AddToDataBase(string temporary_socialSecurityNumber, string temporary_name, DateTime accountExpirationDate_temporary,
                                  string temporary_codeName, string temporaryCode_username, string loggedOnUser_username)
        {
            using (DataClass_afloeserDataContext context = new DataClass_afloeserDataContext())
            {
                try
                {
                    AfloeserBrugere newUser = new AfloeserBrugere();

                    newUser.CPR               = temporary_socialSecurityNumber;
                    newUser.Navn              = temporary_name;
                    newUser.StartDato         = DateTime.Now;
                    newUser.SlutDato          = accountExpirationDate_temporary;
                    newUser.Kategori          = temporary_codeName;
                    newUser.TempCode_username = temporaryCode_username;
                    newUser.Opretter          = loggedOnUser_username;
                    newUser.Deleted           = false;

                    context.AfloeserBrugeres.InsertOnSubmit(newUser);
                    context.SubmitChanges();

                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Exemplo n.º 2
0
        public bool DeleteInDataBase(int db_ID, string loggedInUser_username, DateTime disablingDateTime)
        {
            using (DataClass_afloeserDataContext context = new DataClass_afloeserDataContext())
            {
                try
                {
                    AfloeserBrugere userInDB = context.AfloeserBrugeres.Where(a => a.ID == db_ID).FirstOrDefault();

                    userInDB.Deleted         = true;
                    userInDB.DeletedBy       = loggedInUser_username;
                    userInDB.DeletedDateTime = disablingDateTime;
                    context.SubmitChanges();

                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }