Esempio n. 1
0
        public async Task CreateAsync(CreateMotorcycleViewModel inputModel)
        {
            var motorcycle = AutoMapperConfig.MapperInstance.Map <Motorcycle>(inputModel);

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

            await this.motorcyclesRepository.AddAsync(motorcycle);

            await this.motorcyclesRepository.SaveChangesAsync();
        }
        public async Task <IActionResult> Create(CreateMotorcycleViewModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(inputModel));
            }

            await this.motorcyclesService.CreateAsync(inputModel);

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