public async Task <ActionResult <Property> > PostProperty(Guid portfolioId, PropertyCreateDto @property)
        {
            //var address = _mapper.Map<Address>(@property.Address);
            var portfolio = await _portfolioService.GetPortfolio(portfolioId);

            var newProperty = _mapper.Map <Property>(@property);
            var result      = await _propertyService.CreateProperty(portfolio, newProperty);

            return(CreatedAtAction("GetProperty", new { id = result.Id }, result));
        }
Esempio n. 2
0
        public async Task <ActionResult <PropertyDetailDto> > CreateProperty(Guid portfolioId, PropertyCreateDto @property)
        {
            if (ModelState.IsValid)
            {
                var newProperty = _mapper.Map <Property>(@property);
                await _propertyService.CreateProperty(newProperty, portfolioId);

                return(CreatedAtAction("GetPropertyById", new { portfolioId, newProperty.Id }));
            }
            return(BadRequest(ModelState));
        }
Esempio n. 3
0
        public async Task <IActionResult> CreateProperty([FromBody] SaveEditPropertyResource resource)
        {
            if (await _propertyService.CheckIfPropertyTitleExists(resource.Title))
            {
                return(BadRequest(_response.Error("Property with same title already exists")));
            }

            var property = _mapper.Map <Property>(resource);

            property = await _propertyService.CreateProperty(property, User.GetUserId());

            var propertyResource = _mapper.Map <PropertyResource>(property);

            return(Ok(_response.Ok(propertyResource)));
        }
Esempio n. 4
0
        public ActionResult Create(PropertyFormViewModel createProperty)
        {
            var property = Mapper.Map <PropertyFormViewModel, Property>(createProperty);

            if (ModelState.IsValid)
            {
                propertyService.CreateProperty(property);
                TempData.Add("flash", new FlashSuccessViewModel("Your property details have been created successfully."));
                return(RedirectToAction("Edit", new { id = property.Id }));
            }
            else
            {
                TempData.Add("flash", new FlashDangerViewModel("There was an error saving property"));
            }
            return(View(createProperty));
        }
        public ActionResult Create(PropertyViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var model = new Property();

                model.InjectFrom <UnflatLoopValueInjection>(viewModel);

                PropertyService.CreateProperty(model);

                return(RedirectToAction("Manager"));
            }


            return(View(viewModel));
        }
        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"));
        }
Esempio n. 7
0
        public ActionResult Create(PropertyViewModel model)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>()
            {
                { "Name", model.Name },
                { "Description", model.Description },
            };

            try
            {
                _propertyService.CreateProperty(new List <KeyValuePair <string, string> > (dictionary));

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }