public List <TemporaryUser> TemporaryUserIsCreated(string temporary_socialSecurityNumber, DateTime startDateTime, string temporary_codeName_prefix) { List <TemporaryUser> list = new List <TemporaryUser>(); using (DataClass_afloeserDataContext context = new DataClass_afloeserDataContext()) { var koderIBrug_list = (from table in context.AfloeserBrugeres where table.CPR == temporary_socialSecurityNumber && table.StartDato <startDateTime && table.SlutDato> startDateTime && //GetCodeNamePrefix(table.Kategori) == temporary_codeName_prefix && table.Deleted != true select new { id = table.ID, kategori = table.Kategori, tempCode_username = table.TempCode_username, startDato = table.StartDato, slutDato = table.SlutDato, opretter = table.Opretter, deleted = table.Deleted } ).ToList(); foreach (var item in koderIBrug_list) { if (GetCodeNamePrefix(item.kategori) == temporary_codeName_prefix) { list.Add(new TemporaryUser(item.id, item.kategori, item.tempCode_username, item.startDato, item.slutDato, item.opretter)); } } } return(list); }
public List <TemporaryUser> GetTemporayCodesInUse() { List <TemporaryUser> list = new List <TemporaryUser>(); using (DataClass_afloeserDataContext context = new DataClass_afloeserDataContext()) { DateTime today = DateTime.Now; var koderIBrug_list = (from table in context.AfloeserBrugeres where table.SlutDato >= today && (table.Deleted != true || table.Deleted == null) select new { id = table.ID, kategori = table.Kategori, tempCode_username = table.TempCode_username, startDato = table.StartDato, slutDato = table.SlutDato, opretter = table.Opretter, deleted = table.Deleted } ).ToList(); foreach (var item in koderIBrug_list) { list.Add(new TemporaryUser(item.id, item.kategori, item.tempCode_username, item.startDato, item.slutDato, item.opretter)); } return(list); } }
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); } } }
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); } } }