public IActionResult Create()
        {
            var estateCategories = this.estateCategoriesService.AllEstateCategoriesAsync <EstateCategoriesSelectList>();
            var viewModel        = new EstateCreateInputModel()
            {
                EstateCategories = estateCategories,
            };

            return(this.View(viewModel));
        }
        public async Task <IActionResult> Create(EstateCreateInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            await this.estatesService.CreateEstateAsync(input);

            return(this.Redirect("/"));
        }
예제 #3
0
        public async Task CreateEstateAsync(EstateCreateInputModel input)
        {
            var estate = new Estate()
            {
                Number           = input.Number,
                Title            = input.Title,
                Description      = input.Description,
                EstateCategoryId = input.EstateCategoryId,
                OwnerId          = input.OwnerId,
            };

            await this.estatesRepository.AddAsync(estate);

            await this.estatesRepository.SaveChangesAsync();
        }