public async Task CreatePeriodAsync(CreatePeriodBindingModel bindingModel) { var period = Mapper.Map <Period>(bindingModel); await this.periodsRepository.AddAsync(period); await this.periodsRepository.SaveChangesAsync(); }
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)); }