public async Task <IActionResult> AddPropertyDocument([Bind(include: "Documents")] PropertyCreateView property) { var user = await _userManager.FindByNameAsync(User.Identity.Name); ViewBag.DocumentTypes = await _propertyDocumentService.GetDocumentTypes(user); property.Documents.Add(new DocumentUploader()); return(PartialView("PropertyDocuments", property)); }
public async Task <IActionResult> Create(Guid portfolioId) { var portfolio = await _portfolioService.GetPortfolioById(portfolioId); var property = new PropertyCreateView { Portfolio = portfolio }; return(View(property)); }
public async Task <IActionResult> Create(PropertyCreateView propertyCreateView) { if (ModelState.IsValid) { var property = _mapper.Map <Property>(propertyCreateView); var new_property = await _propertyService.CreateProperty(property); if (propertyCreateView.Images != null && propertyCreateView.Images.Any()) { try { await _propertyImageService.CreateImagesForProperty(new_property, propertyCreateView.Images); } catch (BadImageFormatException ex) { ModelState.AddModelError("Images", ex.Message); return(View(propertyCreateView)); } catch (Exception ex) { ModelState.AddModelError("Images", ex.Message); return(View(propertyCreateView)); } } if (propertyCreateView.Documents != null && propertyCreateView.Documents.Any()) { try { await _propertyDocumentService.CreatePropertyDocumentsForProperty(new_property, propertyCreateView.Documents); } catch (Exception ex) { ModelState.AddModelError("Documents", ex.Message); return(View(propertyCreateView)); } } new_property.CreatedDate = DateTime.Now; new_property.Address.CreatedDate = DateTime.Now; await _propertyService.SaveAsync(); return(RedirectToAction("Details", "Portfolio", new { id = propertyCreateView.Portfolio.Id }).WithSuccess("Success", "Property Created successfully.")); } return(View(propertyCreateView).WithDanger("Error", "Please fix the errors")); }