public AnimalsInputModel AddFeeDropDown()
        {
            var model         = new AnimalsInputModel();
            var feeCollection = this.feeRepository.AllAsNoTracking()
                                .Select(x => new FeeDropDown
            {
                Id   = x.Id,
                Name = x.Name,
            }).ToList();

            model.Fee = feeCollection;

            return(model);
        }
Example #2
0
        public async Task <IActionResult> Create(int realEstateId, int propertyId, AnimalsInputModel inputModel)
        {
            this.ViewBag.realEstateId = realEstateId;
            this.ViewBag.propertyId   = propertyId;

            if (!this.ModelState.IsValid)
            {
                var model = this.animalService.AddFeeDropDown();
                return(this.View(model));
            }

            await this.animalService.CreateAsync(inputModel);

            return(this.RedirectToAction("All", "Properties_", new { realEstateId }));
        }
        public async Task CreateAsync(AnimalsInputModel inputModel)
        {
            var animal = new Animal
            {
                PropertyId = inputModel.PropertyId,
                FeeId      = inputModel.FeeId,
                Comment    = inputModel.Comment,
                Id         = inputModel.Id,
                Breed      = inputModel.Breed,
            };

            await this.animalsReporsitory.AddAsync(animal);

            await this.animalsReporsitory.SaveChangesAsync();
        }