public async Task CreateAsync(CreateWeddingInputModel input, string userId)
        {
            var wedding = new Wedding()
            {
                BrideName = input.BrideName,
                GroomName = input.GroomName,
                Location  = input.Location,
                Date      = input.Date,
                Budget    = input.Budget,
                OwnerId   = userId,
            };

            await this.weddingRepository.AddAsync(wedding);

            await this.weddingRepository.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(CreateWeddingInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            var user = await this.userManager.GetUserAsync(this.User);

            try
            {
                await this.weddingService.CreateAsync(input, user.Id);
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError(string.Empty, ex.Message);
                return(this.View(input));
            }

            return(this.Redirect("/MyWedding/Index"));
        }