public async Task <IActionResult> Update(string id, int realEstateId, CreateResidentsInputModel inputModel) { this.ViewBag.realEstateId = realEstateId; if (!this.ModelState.IsValid) { var model = this.residentsService.Get(id); return(this.View(model)); } await this.residentsService.Update(id, inputModel); return(this.Redirect($"/Residents/All?propertyId={inputModel.PropertyId}&realEstateId={realEstateId}")); }
public async Task <IActionResult> Create(int propertyId, int realEstateId, CreateResidentsInputModel inputModel) { if (!this.ModelState.IsValid) { this.ViewBag.propertyId = propertyId; this.ViewBag.realEstateId = realEstateId; var model = this.residentsService.AddFee(); return(this.View(model)); } await this.residentsService.CreateAsync(inputModel); return(this.Redirect($"/Residents/All?propertyId={propertyId}&realEstateId={realEstateId}")); }
public CreateResidentsInputModel AddFee() { var model = new CreateResidentsInputModel(); var feeCollection = this.feeRepository.AllAsNoTracking() .Select(x => new FeeDropDown { Id = x.Id, Name = x.Name, }).ToList(); model.Fee = feeCollection; return(model); }
public async Task Update(string residentId, CreateResidentsInputModel inputModel) { var resident = this.resRepository.All().Where(x => x.Id == residentId).FirstOrDefault(); resident.FirstName = inputModel.FirstName; resident.MiddleName = inputModel.MiddleName; resident.LastName = inputModel.LastName; resident.Telephone = inputModel.Telephone; resident.Email = inputModel.Email; resident.Gender = inputModel.Gender; resident.FeeId = inputModel.FeeId; resident.PropertyId = inputModel.PropertyId; resident.ResidentType = inputModel.ResidentType; resident.DateOfBirth = inputModel.DateOfBirth; this.resRepository.Update(resident); await this.resRepository.SaveChangesAsync(); }
public async Task CreateAsync(CreateResidentsInputModel inputModel) { var resident = new Resident() { FirstName = inputModel.FirstName, MiddleName = inputModel.MiddleName, LastName = inputModel.LastName, Telephone = inputModel.Telephone, Email = inputModel.Email, DateOfBirth = inputModel.DateOfBirth, FeeId = inputModel.FeeId, Gender = inputModel.Gender, PropertyId = inputModel.PropertyId, ResidentType = inputModel.ResidentType, }; await this.resRepository.AddAsync(resident); await this.resRepository.SaveChangesAsync(); }