Exemplo n.º 1
0
        public async Task CreatePeriodAsync(CreatePeriodBindingModel bindingModel)
        {
            var period = Mapper.Map <Period>(bindingModel);

            await this.periodsRepository.AddAsync(period);

            await this.periodsRepository.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreatePeriod(CreatePeriodBindingModel bindingModel)
        {
            if (ModelState.IsValid)
            {
                if (!this.periodsService.ContainsThisPeriod(bindingModel.RoomId, bindingModel.StartDate, bindingModel.EndDate))
                {
                    await this.periodsService.CreatePeriodAsync(bindingModel);

                    return(this.RedirectToAction("Periods", new { id = bindingModel.RoomId }));
                }
            }

            var viewModel = new CreatePeriodViewModel
            {
                RoomId = bindingModel.RoomId
            };

            return(this.View(viewModel));
        }