public void ToString_NårNavnVertLagaTilString_VertDetFornuftig() { const string fornavn = "Adrian"; const string etternavn = "Gustaviusen"; var navn = new Navn(fornavn, etternavn); navn.ToString().ShouldBe(fornavn + ' ' + etternavn); }
private void Navn_Validating(object sender, CancelEventArgs e) { if (Navn.Text.Length > 15) { e.Cancel = true; Navn.Select(0, Navn.Text.Length); // Set the ErrorProvider error with the text to display. this.epRegnskab.SetError(Navn, "Dette er en fejl"); } }
public override string ToString() { // Formaterer for å få fine kolonner return Navn.PadRight(20) + " " + Formue.ToString().PadLeft(10); }
public override int GetHashCode() { return(Navn.GetHashCode()); }
public void opretKunde() { Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Indtast Navn: "); Console.WriteLine("Indtast Efternavn: "); Console.WriteLine("Indtast Adresse: "); Console.WriteLine("Indtast Postnummer: "); Console.WriteLine("Indtast Telefonnummer: "); Console.WriteLine("Indtast E-Mail adresse: "); Console.SetCursorPosition(50, 7); Navn = Console.ReadLine(); erDerTal = Navn.Any(c => char.IsDigit(c)); while (erDerTal) { Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("Navn må ikke indeholde tal, prøv igen:"); Console.SetCursorPosition(50, 7); Navn = Console.ReadLine(); erDerTal = Navn.Any(c => char.IsDigit(c)); } Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("Navn:"); Console.SetCursorPosition(50, 7); Console.WriteLine(Navn); Console.SetCursorPosition(50, 8); Efternavn = Console.ReadLine(); erDerTal = Efternavn.Any(c => char.IsDigit(c)); while (erDerTal) { Console.SetCursorPosition(0, 8); Console.Write(" "); Console.SetCursorPosition(0, 8); Console.WriteLine("Efternavn må ikke indeholde tal, prøv igen:"); Console.SetCursorPosition(50, 8); Efternavn = Console.ReadLine(); erDerTal = Efternavn.Any(c => char.IsDigit(c)); } Console.SetCursorPosition(0, 8); Console.Write(" "); Console.SetCursorPosition(0, 8); Console.WriteLine("Efternavn:"); Console.SetCursorPosition(50, 8); Console.WriteLine(Efternavn); Console.SetCursorPosition(50, 9); Adr = Console.ReadLine(); Console.SetCursorPosition(0, 9); Console.Write(" "); Console.SetCursorPosition(0, 9); Console.WriteLine("Adresse:"); Console.SetCursorPosition(50, 9); Console.WriteLine(Adr); Console.SetCursorPosition(50, 10); bool PostNrLoop = true; while (PostNrLoop) { try { Postnr = Convert.ToInt32(Console.ReadLine()); if (Postnr.ToString().Length != 4) { Console.SetCursorPosition(0, 10); Console.Write(" "); Console.SetCursorPosition(0, 10); Console.WriteLine("Et postnummer er altid 4 cifre, prøv igen:"); Console.SetCursorPosition(50, 10); } else { PostNrLoop = false; } } catch (Exception) { Console.SetCursorPosition(0, 10); Console.Write(" "); Console.SetCursorPosition(0, 10); Console.WriteLine("Et postnummer er altid et tal med 4 cifre, prøv igen:"); Console.SetCursorPosition(50, 10); } } Console.SetCursorPosition(0, 10); Console.Write(" "); Console.SetCursorPosition(0, 10); Console.WriteLine("Postnummer:"); Console.SetCursorPosition(50, 10); Console.WriteLine(Postnr); Console.SetCursorPosition(50, 11); bool TlfLoop = true; while (TlfLoop) { try { Tlf = Convert.ToInt32(Console.ReadLine()); if (Tlf.ToString().Length != 8) { Console.SetCursorPosition(0, 11); Console.Write(" "); Console.SetCursorPosition(0, 11); Console.WriteLine("Et telefonnummer er altid 8 cifre:"); Console.SetCursorPosition(50, 11); } else { TlfLoop = false; } } catch (Exception) { Console.SetCursorPosition(0, 11); Console.Write(" "); Console.SetCursorPosition(0, 11); Console.WriteLine("Et telefonnummer er altid tal med 8 cifre:"); Console.SetCursorPosition(50, 11); } } Console.SetCursorPosition(0, 11); Console.Write(" "); Console.SetCursorPosition(0, 11); Console.WriteLine("Telefonnummer:"); Console.SetCursorPosition(50, 11); Console.WriteLine(Tlf); Console.SetCursorPosition(50, 12); Email = Console.ReadLine(); while (!IsValidEmail(Email)) { Console.SetCursorPosition(0, 12); Console.Write(" "); Console.SetCursorPosition(0, 12); Console.WriteLine("Ugyldig indtastning, prøv igen:"); Console.SetCursorPosition(50, 12); Email = Console.ReadLine(); } Console.SetCursorPosition(0, 12); Console.Write(" "); Console.SetCursorPosition(0, 12); Console.WriteLine("Email adresse:"); Console.SetCursorPosition(50, 12); Console.WriteLine(Email); OpretDato = DateTime.Now.ToString("d"); SQL.Change("insert into Kunder values('" + Navn + "', '" + Efternavn + "', '" + Adr + "', " + Postnr + ", " + Tlf + ", '" + Email + "', '" + OpretDato + "')"); kunder.Add(new Kunde(Navn, Efternavn, Adr, Postnr, Tlf, Email, OpretDato)); }
public override int GetHashCode() { return(Navn.GetHashCode() ^ Pris.GetHashCode() ^ Lager.GetHashCode()); }
public HttpResponseMessage Post( //[FromUri] string firstname, [FromUri] string lastname, [FromUri] string Username, [FromUri] string password, [FromUri] string homeroomClass) [FromBody]Models.Student student) { var numberOfErrors = 0; //var json = jsonBytes.ConvertToString(); //var student = json.DeserializeJson<Models.Student>(); Action<BookingSystemDataContext> submitChanges = db => { try { db.SubmitChanges(); } catch (Exception e) { numberOfErrors++; Debug.WriteLine("DEBUG: " + e.Message); } }; var classId = 0; var cls = _db.Holds.FirstOrDefault(h => h.Navn.Equals(student.HomeRoomClass.Name)); // checks if cls exits in table if (cls != null) { // checks if it is an eal mail and if it exists in the database if (student.Username.Contains("@edu.eal.dk") && _db.Brugers.FirstOrDefault(b => b.Brugernavn.Equals(student.Username)) == null) { classId = cls._id; student.Username.Replace("@edu.eal.dk", ""); // remove the ending submitChanges(_db); Debug.WriteLine("Homeroom name: " + student.HomeRoomClass.Name); Debug.WriteLine("Finished searching through holds, number of errors: " + numberOfErrors); Navn name = new Navn { Fornavn = student.Name.FirstName, Efternavn = student.Name.LastName }; _db.Navns.InsertOnSubmit(name); submitChanges(_db); Debug.WriteLine("Finished adding a name, number of errors: " + numberOfErrors); Bruger user = new Bruger { Navn_id = name._id, Brugernavn = student.Username, Password = student.Password }; _db.Brugers.InsertOnSubmit(user); submitChanges(_db); Debug.WriteLine("Finished adding a user, number of errors: " + numberOfErrors); Studerende stud = new Studerende { Godkendt = 0, Bruger_id = user._id, Hold_id = classId }; _db.Studerendes.InsertOnSubmit(stud); submitChanges(_db); Debug.WriteLine("Finished adding a student, number of errors: " + numberOfErrors); } else numberOfErrors++; } else { numberOfErrors++; Debug.WriteLine("DEBUG: Couldn't find the specified homeroom"); } var message = new HttpResponseMessage(); if (numberOfErrors != 0) message.Forbidden("Errors: " + numberOfErrors); else message.OK("{\"Response\":\"OK\"}"); return message; }