コード例 #1
0
        public async Task CreateAsync(CreateBusViewModel inputModel)
        {
            var bus = AutoMapperConfig.MapperInstance.Map <Bus>(inputModel);

            bus.Id = Guid.NewGuid().ToString();

            await this.busesRepository.AddAsync(bus);

            await this.busesRepository.SaveChangesAsync();
        }
コード例 #2
0
        public async Task <IActionResult> Create(CreateBusViewModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(inputModel));
            }

            await this.busesService.CreateAsync(inputModel);

            return(this.RedirectToAction("MyBuses"));
        }