예제 #1
0
        public async Task <IActionResult> PutOpeningTimeModel([FromRoute] int id, [FromBody] OpeningTimeModel openingTimeModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != openingTimeModel.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> PostOpeningTimeModel([FromBody] OpeningTimeModel openingTimeModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.OpeningTimes.Add(openingTimeModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOpeningTimeModel", new { id = openingTimeModel.Id }, openingTimeModel));
        }
예제 #3
0
        public static void Initialize(MainContext context)
        {
            if (context.Queues.Any())
            {
                return;
            }

            var image = new ImagesModel {
                Url = "http://via.placeholder.com/350x150"
            };

            context.Images.Add(image);
            context.SaveChanges();

            var company = new CompanyModel
            {
                Category = "Doctor",
                Email    = "*****@*****.**",
                Location = "Karlsruhe, ZKM",
                Name     = "ZKM Surgery GmbH",
                Phone    = "+490123456789",
                Website  = "https://zkmsurgery.de",
                ImageId  = image.Id
            };

            var company2 = new CompanyModel
            {
                Category = "Utilities",
                Email    = "*****@*****.**",
                Location = "Munchen",
                Name     = "Sauermacher GmbH",
                Phone    = "+4901234534789",
                Website  = "https://sauchermacher.de",
                ImageId  = image.Id
            };

            var openingTime = new OpeningTimeModel
            {
                Open  = DateTime.Now.AddHours(-5),
                Close = DateTime.Now.AddHours(+25)
            };

            context.Companies.Add(company);
            context.Companies.Add(company2);
            context.OpeningTimes.Add(openingTime);
            context.SaveChanges();

            var queue = new QueueModel
            {
                AllowMultipleEntries   = false,
                AverageWaitTimeSeconds = 600,
                CompanyId         = company.Id,
                Description       = "Doctor's queue",
                ImageId           = image.Id,
                Location          = "Room 18/B",
                Name              = "Dr. Peter Artoli's queue",
                MaxLength         = 20,
                OpeningTimeId     = openingTime.Id,
                RequireSignup     = false,
                AtTheReadyTimeout = 300,
                AtTheReadyCount   = 1
            };

            var queue2 = new QueueModel
            {
                AllowMultipleEntries   = false,
                AverageWaitTimeSeconds = 400,
                CompanyId         = company2.Id,
                Description       = "Utility bill queue",
                ImageId           = image.Id,
                Location          = "Room 1/A",
                Name              = "Customer services queue",
                MaxLength         = 10,
                OpeningTimeId     = openingTime.Id,
                RequireSignup     = false,
                AtTheReadyTimeout = 120,
                AtTheReadyCount   = 1
            };

            context.Queues.Add(queue);
            context.SaveChanges();

            var user = new UserModel {
                Email     = "*****@*****.**",
                Name      = "IamYourFirstUser",
                Phone     = "+49001912836",
                CompanyId = company.Id
            };

            var user2 = new UserModel
            {
                Email     = "*****@*****.**",
                Name      = "IamYourSecondUser",
                Phone     = "+49001912336",
                CompanyId = company2.Id
            };

            var user3 = new UserModel
            {
                Email     = "*****@*****.**",
                Name      = "IamYourThirdUser",
                Phone     = "+490019123836",
                CompanyId = company.Id
            };

            context.Users.Add(user);
            context.Users.Add(user2);
            context.Users.Add(user3);
            context.SaveChanges();

            InitializeMetaData(context);
        }