Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Förnamn,Efternamn,Roll")] Anställd anställd)
        {
            if (id != anställd.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(anställd);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnställdExists(anställd.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(anställd));
        }
Ejemplo n.º 2
0
        private static void SeedUsers(UserManager <Anställd> userManager)
        {
            if (userManager.FindByEmailAsync("johndoe@localhost").Result == null)
            {
                Anställd user = new Anställd();
                //user.UserName = "******";
                //user.Email = "johndoe@localhost";
                user.Förnamn   = "John";
                user.Efternamn = "Doe";

                IdentityResult result = userManager.CreateAsync(user, "P@ssw0rd1!").Result;

                if (result.Succeeded)
                {
                    userManager.AddToRoleAsync(user, "User").Wait();
                }
            }


            if (userManager.FindByEmailAsync("alex@localhost").Result == null)
            {
                Anställd user = new Anställd();
                //user.UserName = "******";
                //user.Email = "alex@localhost";
                user.Förnamn   = "Alex";
                user.Efternamn = "Calingasan";

                IdentityResult result = userManager.CreateAsync(user, "P@ssw0rd1!").Result;

                if (result.Succeeded)
                {
                    userManager.AddToRoleAsync(user, "Admin").Wait();
                }
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Förnamn,Efternamn,Roll")] Anställd anställd)
        {
            if (ModelState.IsValid)
            {
                _context.Add(anställd);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(anställd));
        }
Ejemplo n.º 4
0
        private void LoggaInKnapp_Click(object sender, EventArgs e)
        {
            int      ID = int.Parse(IDtext.Text);
            Anställd A  = Businesmanager.LoggaIn(ID, Lösenordtext.Text);

            if (A == null)
            {
                MessageBox.Show("Inloggningen misslyckades", "Error");
            }
            else
            {
                Start start = new Start(Businesmanager);
                this.Hide();
                start.ShowDialog();
                this.Close();
            }
        }
Ejemplo n.º 5
0
        public Start(BusinessManager businessManager)
        {
            //Laddar in saker i listorna
            InitializeComponent();


            BusinessManager = businessManager;


            Medlem   M = new Medlem(10, "Calle", 0708555789, "*****@*****.**", new List <Bokning>());
            Anställd A = new Anställd(10, "Lisa", "LOL", "expedit", new List <Bokning>());
            Bok      B = new Bok(1245, "How do?");


            BusinessManager.MedRepo.Medlemmar.Add(M);
            BusinessManager.AnstRepo.anställda.Add(A);
            BusinessManager.BokRepo.Böcker.Add(B);


            Uppdatera();
            ListboxBöcker.SelectionMode = SelectionMode.MultiExtended;
        }
Ejemplo n.º 6
0
        private void SkapaBokninKnapp_Click(object sender, EventArgs e)
        {
            //Knapp för att skapa en bokning
            Anställd A   = BusinessManager.GetAnställd(BusinessManager.AnstRepo.inloggad);
            int      MNr = int.Parse(MedlemsIdBox.Text);

            //Skapar en lista med böckerna som är valda
            List <Bok> B = new List <Bok>();

            foreach (Bok b in ListboxBöcker.SelectedItems)
            {
                B.Add(b);
            }



            Bokning Bokn = A.skapaBokning(MNr, B, BusinessManager.AnstRepo.inloggad, BusinessManager);



            //En box för att se så informationen stämmer
            DialogResult Svar;

            Svar = MessageBox.Show($"Medlem: {Bokn.medlem.namn}\nAnställd: {Bokn.anställd.namn}", "stämmer detta?", MessageBoxButtons.YesNo);
            if (Svar == DialogResult.No)
            {
                Close();
            }
            else if (Svar == DialogResult.Yes)
            {
                BusinessManager.BoknRepo.AddBokning(Bokn);
                MessageBox.Show($"{Bokn.BokningsNr}", "Ditt boknings nummer är");
                BokadeBöckerlista.Items.Add(B);
                Uppdatera();
            }
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Reservartion[] patients  = new Reservartion[100];
            Anställd[]     anställda = new Anställd[100];

            bool shouldNotExit   = true;
            int  patientCounter  = 0;
            int  anställdCounter = 0;

            while (shouldNotExit)
            {
                WriteLine("1. Skapa bokning");
                WriteLine("2. Lista bokningar");
                WriteLine("3. Registrera kund");
                WriteLine("4. Registrera anställd");
                WriteLine("5. Lista anställda");
                WriteLine("6. Avsluta");

                ConsoleKeyInfo keyPressed = ReadKey(true);

                Clear();

                switch (keyPressed.Key)
                {
                case ConsoleKey.D1:
                case ConsoleKey.NumPad1:


                    Write("Kund (Personnummer): ");
                    string personNummer = ReadLine();

                    WriteLine();

                    Write("Anledning: ");
                    string anledning = ReadLine();

                    WriteLine();

                    Write("Utförs av (ID): ");
                    string tandläkare = ReadLine();

                    Write("Datum (yyyy-mm-dd hh:mm): ");
                    DateTime datum = Convert.ToDateTime(ReadLine());

                    WriteLine();

                    WriteLine("Är detta rätt? (J)a (N)ej");
                    keyPressed = ReadKey(true);

                    if (keyPressed.Key == ConsoleKey.Y)
                    {
                        continue;
                    }

                    Reservartion patient = new Reservartion(personNummer, anledning, tandläkare, datum);

                    patients[patientCounter++] = patient;


                    break;


                case ConsoleKey.D2:

                    WriteLine("Patient\t\t\t\t Anledning\t  Tid");
                    WriteLine("-------------------------------------------------------");

                    foreach (Reservartion patient1 in patients)
                    {
                        if (patient1 == null)
                        {
                            continue;
                        }

                        {
                            WriteLine($"{patient1.GetfullName()}, {patient1.GetpersonNummer()}, {patient1.Getanledning()}, {patient1.GetDatum()}");
                        }
                    }

                    ReadKey();

                    break;

                case ConsoleKey.D3:

                    Write("Förnamn: ");
                    string förNamn = ReadLine();

                    Write("Efternamn: ");
                    string efterNamn = ReadLine();

                    Write("Personnummer: ");
                    string personNummer1 = ReadLine();

                    Write("Telefonnummer: ");
                    string telefonNummer = ReadLine();

                    Write("E-mail: ");
                    string email = ReadLine();

                    Patient patientGrid = new Patient(förNamn, efterNamn, personNummer1, telefonNummer, email);

                    break;

                case ConsoleKey.D4:

                    Write("Förnamn: ");
                    string förnamnAnställd = ReadLine();

                    Write("Efternamn: ");
                    string efternamnAnställd = ReadLine();

                    Write("Personnummer: ");
                    string personNummerAnställd = ReadLine();

                    Write("Telefonnummer: ");
                    string telefonNummerAnställd = ReadLine();

                    Write("E-mail: ");
                    string emailAnställd = ReadLine();

                    WriteLine();

                    Write("ID: ");
                    string idAnställd = ReadLine();

                    Write("Lön: ");
                    decimal lön = decimal.Parse(ReadLine());

                    WriteLine();

                    WriteLine("(1) Tandläkare  (2) Tandhygienist");

                    //if (keyPressed.Key == ConsoleKey.D1)
                    //{
                    //    WriteLine("Roll: 1");
                    //}
                    //else if (keyPressed.Key == ConsoleKey.D2)
                    //{
                    //    WriteLine("Roll: 2");
                    //}

                    WriteLine();

                    WriteLine("Är detta korrekt? (J)a (N)ej");
                    bool validKeyPressed;
                    do
                    {
                        ConsoleKeyInfo keyPressed1 = ReadKey(true);
                        validKeyPressed = keyPressed1.Key == ConsoleKey.J ||
                                          keyPressed1.Key == ConsoleKey.N;
                    }while (!validKeyPressed);
                    WriteLine("Du tryckte på J eller N");

                    Anställd enAnställd = new Anställd(förnamnAnställd, efternamnAnställd, personNummerAnställd, telefonNummerAnställd, emailAnställd, idAnställd, lön);

                    anställda[anställdCounter++] = enAnställd;

                    ReadKey();

                    break;

                case ConsoleKey.D5:

                    WriteLine("Anställd\t\t\t ID");
                    WriteLine("-----------------------------------------------");

                    foreach (Anställd anställd in anställda)
                    {
                        if (anställd == null)
                        {
                            continue;
                        }
                        {
                            WriteLine($"{anställd.GetFörNamn()} {anställd.GetEfterNamn()}, {anställd.GetId()}");
                        }
                    }

                    ReadKey();

                    break;

                case ConsoleKey.D6:
                case ConsoleKey.NumPad6:

                    shouldNotExit = false;

                    break;
                }

                Clear();
            }
        }