コード例 #1
0
        public async Task <IActionResult> Edit(PropertyDetailDTO property, List <IFormFile> images, List <DocumentUploader> documents)
        {
            if (ModelState.IsValid)
            {
                var updatedProperty = _mapper.Map <Property>(property);
                var portfolio       = _mapper.Map <Portfolio>(property.Portfolio);
                if (images.Any())
                {
                    var imagesSaved = await _propertyImageService.CreateImagesForProperty(updatedProperty, images);
                }
                if (documents.Any())
                {
                    await _propertyDocumentService.CreatePropertyDocumentsForProperty(updatedProperty, documents);
                }

                await _propertyService.UpdateProperty(updatedProperty);

                return(RedirectToAction(nameof(Detail), new { portfolioId = property.Portfolio.Id, propertyId = property.Id })
                       .WithSuccess("Success", "Property Updated Sucessfully!"));
            }
            return(View(property).WithDanger("Error", "Some Errors Occured"));
        }