public bool CheckIfHouseModelHasUsefulData(SellHouseModel model) { if (model.Bedrooms == 0 && model.CarsSpace == 0 && model.Garage == false && model.LivingRooms == 0 && model.NumberofFloors == 0 && model.Pool == false) { return false; } return true; }
public ActionResult SellProperty(SellPropertyModel propertyModel, SellHouseModel houseModel, List<HttpPostedFileBase> files) { var property = Mapper.Map<SellPropertyModel, Property>(propertyModel); property.DueñoId = _repository.First<Account>(x => x.Email == User.Identity.Name).Id; property.Banned = false; if (CheckIfHouseModelHasUsefulData(houseModel)) { var casa = Mapper.Map<SellHouseModel, House>(houseModel); //casa.InjectFrom(property); ** Doesn't work as intended, research needed. ** casa.Id = property.Id; casa.IsArchived = false; casa.LandArea = property.LandArea; casa.ConstructionArea = property.ConstructionArea; casa.Price = property.Price; casa.Suburb = property.Suburb; casa.City = property.City; casa.Country = property.Country; casa.DueñoId = property.DueñoId; casa.NombrePropiedad = property.NombrePropiedad; casa.PropertyDescription = property.PropertyDescription; casa.StartingDate = property.StartingDate; casa.Banned = false; _repository.Create(casa); Success("Casa en venta"); } else { Success("Propiedad en venta"); _repository.Create(property); } /* * Falta agregar como se van a guardar las imagenes so keep it in mind. * */ return RedirectToAction("ListProperties", "Properties"); }