Exemplo n.º 1
0
        public async Task <IActionResult> Update(int id, CreatePropertiesInputModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                var model = this.propertiesService.Get(id);
                return(this.View(model));
            }

            await this.propertiesService.Update(id, inputModel);

            return(this.Redirect($"/Properties_/All?realEstateId={inputModel.RealEstateId}"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(int realEstateId, CreatePropertiesInputModel inputModel)
        {
            if (!this.ModelState.IsValid)
            {
                this.ViewBag.realEstateId = realEstateId;
                var model = this.propertiesService.AddFee(realEstateId);
                return(this.View(model));
            }

            await this.propertiesService.CreateAsync(inputModel);

            return(this.Redirect($"/Properties_/All?realEstateId={realEstateId}"));
        }
Exemplo n.º 3
0
        public async Task Update(int id, CreatePropertiesInputModel inputModel)
        {
            var fee = this.repository.All().Where(x => x.Id == id).FirstOrDefault();

            fee.Number = inputModel.Number;
            fee.Floor  = inputModel.Floor;
            fee.FeeId  = inputModel.FeeId;
            fee.PercentageCommonParts = inputModel.PercentageCommonParts;
            fee.PropertyOwnership     = inputModel.PropertyOwnership;
            fee.PropertyType          = inputModel.PropertyType;
            fee.RealEstateId          = inputModel.RealEstateId;
            fee.Size = inputModel.Size;
            this.repository.Update(fee);
            await this.repository.SaveChangesAsync();
        }
Exemplo n.º 4
0
        public CreatePropertiesInputModel AddFee(int realEstateId)
        {
            var model         = new CreatePropertiesInputModel();
            var feeCollection = this.feeRepository
                                .AllAsNoTracking()
                                .Where(x => x.RealEstateId == realEstateId)
                                .Select(x => new FeeDropDown
            {
                Id   = x.Id,
                Name = x.Name,
            }).ToList();

            model.Fee = feeCollection;

            return(model);
        }
Exemplo n.º 5
0
        public async Task CreateAsync(CreatePropertiesInputModel inputModel)
        {
            var property = new Property()
            {
                Number = inputModel.Number,
                Floor  = inputModel.Floor,
                Size   = inputModel.Size,
                FeeId  = inputModel.FeeId,
                PercentageCommonParts = inputModel.PercentageCommonParts,
                PropertyOwnership     = inputModel.PropertyOwnership,
                PropertyType          = inputModel.PropertyType,
                RealEstateId          = inputModel.RealEstateId,
            };

            await this.repository.AddAsync(property);

            await this.repository.SaveChangesAsync();
        }