Exemple #1
0
        public async Task <ActionResult <CareGiverEntity> > RegisterCareGiver(CareGiverEntity careGiverEntity)
        {
            _context.CareGivers.Add(careGiverEntity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCareGiverEntity", new { id = careGiverEntity.ID }, careGiverEntity));
        }
Exemple #2
0
        public async Task <IActionResult> PutCareGiverEntity(int id, CareGiverEntity careGiverEntity)
        {
            if (id != careGiverEntity.ID)
            {
                return(BadRequest());
            }

            _context.Entry(careGiverEntity).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CareGiverEntityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
        public static void Initialize(HelpToHealthApiContext context)
        {
            context.Database.EnsureCreated();

            context.Database.ExecuteSqlRaw("TRUNCATE TABLE CareGivers");
            context.Database.ExecuteSqlRaw("TRUNCATE TABLE CareVolunteers");

            var organisation = new OrganisationEntity
            {
                Email            = "*****@*****.**",
                Name             = "Hospital A",
                OrganisationType = "Public",
                CareGivers       = new List <CareGiverEntity>()
            };

            var careGivers = new CareGiverEntity[]
            {
                new CareGiverEntity
                {
                    Address     = "1 Apple Park Way, Cupertino, CA 95014, USA",
                    Email       = "*****@*****.**",
                    Name        = "John Smith",
                    PhoneNumber = "07813116321"
                },
                new CareGiverEntity
                {
                    Address     = "26 Federal Plaza, New York, NY 10278, USA",
                    Email       = "*****@*****.**",
                    Name        = "Sam Dickkson",
                    PhoneNumber = "07813129431"
                },
                new CareGiverEntity
                {
                    Address     = "Legacy Bldg, Belfast BT3 9DT, UK",
                    Email       = "*****@*****.**",
                    Name        = "Sarah Woodview",
                    PhoneNumber = "07813038729"
                }
            };

            foreach (CareGiverEntity careGiver in careGivers)
            {
                organisation.CareGivers.Add(careGiver);
            }

            context.Organisations.Add(organisation);

            var careVolunteers = new CareVolunteerEntity[]
            {
                new CareVolunteerEntity
                {
                    Address           = "5 Ormonde Cres, Belfast BT6 9FL, UK",
                    PhoneNumber       = "07712345432",
                    Name              = "Faraz Goff",
                    Latitude          = 54.5847523M,
                    Longitude         = -5.891415599999999M,
                    Password          = "******",
                    TrainingCompleted = "No",
                    WillingToDo       = "Shopping",
                    AvailabilityFrom  = "Mon 9am",
                    AvailabilityTo    = "Fri 5pm",
                    Email             = "Email"
                },
                new CareVolunteerEntity
                {
                    Address           = "12 Loopland Parade, Belfast BT6 9EF, UK",
                    PhoneNumber       = "07718437432",
                    Name              = "Tony Ryan",
                    Latitude          = 54.5858078M,
                    Longitude         = -5.893081200000001M,
                    Password          = "******",
                    TrainingCompleted = "No",
                    WillingToDo       = "Shopping",
                    AvailabilityFrom  = "Mon 9am",
                    AvailabilityTo    = "Fri 5pm",
                    Email             = "Email"
                },
                new CareVolunteerEntity
                {
                    Address           = "42 Orby Gardens, Belfast BT5 5HS, UK",
                    PhoneNumber       = "07718437432",
                    Name              = "Koa Sharp",
                    Latitude          = 54.5871322M,
                    Longitude         = -5.8904577M,
                    Password          = "******",
                    TrainingCompleted = "No",
                    WillingToDo       = "Shopping",
                    AvailabilityFrom  = "Mon 9am",
                    AvailabilityTo    = "Fri 5pm",
                    Email             = "Email"
                },
                new CareVolunteerEntity
                {
                    Address           = "6 Balkan St, Belfast BT12 4FG, UK",
                    PhoneNumber       = "07718437432",
                    Name              = "Nusaybah Cairns",
                    Latitude          = 54.5973224M,
                    Longitude         = -5.948408800000002M,
                    Password          = "******",
                    TrainingCompleted = "No",
                    WillingToDo       = "Shopping",
                    AvailabilityFrom  = "Mon 9am",
                    AvailabilityTo    = "Fri 5pm",
                    Email             = "Email"
                },
                new CareVolunteerEntity
                {
                    Address           = "13 Oaklands Antrim BT41 1LS",
                    PhoneNumber       = "07718437432",
                    Name              = "Myra Baxter",
                    Latitude          = 54.714300M,
                    Longitude         = -6.191598M,
                    Password          = "******",
                    TrainingCompleted = "No",
                    WillingToDo       = "Shopping",
                    AvailabilityFrom  = "Mon 9am",
                    AvailabilityTo    = "Fri 5pm",
                    Email             = "Email"
                },
            };

            foreach (var careGiver in careVolunteers)
            {
                context.CareVolunteers.Add(careGiver);
            }


            context.SaveChanges();
        }