示例#1
0
        public async Task <IActionResult> Add(Court model)
        {
            var newItemId = await _courtService.Add(model);

            var openingHours = new List <OpeningHours>()
            {
                new OpeningHours {
                    CourtId = newItemId, DayId = 0, OpeningTime = 10, ClosingTime = 20
                },
                new OpeningHours {
                    CourtId = newItemId, DayId = 1, OpeningTime = 10, ClosingTime = 20
                },
                new OpeningHours {
                    CourtId = newItemId, DayId = 2, OpeningTime = 10, ClosingTime = 20
                },
                new OpeningHours {
                    CourtId = newItemId, DayId = 3, OpeningTime = 10, ClosingTime = 20
                },
                new OpeningHours {
                    CourtId = newItemId, DayId = 4, OpeningTime = 10, ClosingTime = 20
                },
                new OpeningHours {
                    CourtId = newItemId, DayId = 5, OpeningTime = 10, ClosingTime = 20
                },
                new OpeningHours {
                    CourtId = newItemId, DayId = 6, OpeningTime = 10, ClosingTime = 20
                },
            };

            //openingHours.ForEach(async x => await _openingHoursService.Add(x));

            foreach (var item in openingHours)
            {
                await _openingHoursService.Add(item);
            }

            return(Ok(newItemId));
        }
示例#2
0
        public async Task <IActionResult> Add(OpeningHours model)
        {
            var newItemId = await _openingHoursService.Add(model);

            return(Ok(newItemId));
        }