예제 #1
0
        public async Task <ActionResult> CreateAsync(Doctor item)
        {
            if (ModelState.IsValid)
            {
                Doctor newdoctor = await doctorManager.CreateAsync(item);

                return(new OkObjectResult(newdoctor));
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #2
0
        private void FillInitialData()
        {
            DoctorManager  doctorManager;
            PatientManager patientManager;
            var            list = _doctorContext.GetItemsAsync(y => y.Name != "").Result.ToList();

            if (list.Count < 3)
            {
                doctorManager = new DoctorManager(_doctorContext);
                var x = doctorManager.CreateAsync(new Doctor()
                {
                    Name       = "Mikael Seström",
                    Email      = "*****@*****.**",
                    ItemId     = "201012-1425",
                    Speciality = new Speciality()
                    {
                        Id   = "3",
                        Name = "Clinical radiology"
                    },
                    Description = ""
                });

                x = doctorManager.CreateAsync(new Doctor()
                {
                    Name       = "Carina Axel",
                    Email      = "*****@*****.**",
                    ItemId     = "200911-1758",
                    Speciality = new Speciality()
                    {
                        Id   = "2",
                        Name = "Anaesthesia"
                    },
                    Description = ""
                });

                x = doctorManager.CreateAsync(new Doctor()
                {
                    Name       = "Martin Eriksson",
                    Email      = "*****@*****.**",
                    ItemId     = "199005-1875",
                    Speciality = new Speciality()
                    {
                        Id   = "1",
                        Name = "Clinical oncology"
                    },
                    Description = ""
                });
            }

            var list2 = _patientContext.GetItemsAsync(y => y.Name != "").Result.ToList();

            if (list2.Count < 3)
            {
                patientManager = new PatientManager(_patientContext);
                var x = patientManager.CreateAsync(new Patient()
                {
                    Name    = "Henrik Karlsson",
                    Email   = "*****@*****.**",
                    ItemId  = "19860813-1111",
                    Address = new Address()
                    {
                        ItemId  = "111",
                        ZipCode = "121211"
                    },
                    Description = ""
                });

                x = patientManager.CreateAsync(new Patient()
                {
                    Name    = "Erik Henriksson",
                    Email   = "*****@*****.**",
                    ItemId  = "19750612-2222",
                    Address = new Address()
                    {
                        ItemId  = "112",
                        ZipCode = "121211"
                    },
                    Description = ""
                });

                x = patientManager.CreateAsync(new Patient()
                {
                    Name    = "Cecilia Eliasson",
                    Email   = "*****@*****.**",
                    ItemId  = "19600519-3333",
                    Address = new Address()
                    {
                        ItemId  = "113",
                        ZipCode = "122122"
                    },
                    Description = ""
                });
            }
        }