public ActionResult Edit(int id) { RealEstateDTO realEstate = _realEstateService.GetRealEstateById(id); var model = new EditRealEstateViewModel(); model.RealEstateDto = realEstate; ViewBag.ImagePath = model.RealEstateDto.ImagePath; ViewBag.Id = model.RealEstateDto.Id; return(View(model)); }
public ActionResult Add(EditRealEstateViewModel realEstate) { RealEstateDTO real = realEstate.RealEstateDto; if (real.Id == 0) { _realEstateService.AddRealEstateDto(real); _realEstateService.Save(); return(RedirectToAction("Index")); } return(View(real)); }
public ActionResult Edit(EditRealEstateViewModel realEstate, HttpPostedFileBase image) { RealEstateDTO real = realEstate.RealEstateDto; if (image != null) { real.ImageMimeType = image.ContentType; real.ImagePath = "/Content/Files/" + real.Id + "_" + image.FileName; } if (real.Id == 0) { return(Add(realEstate)); } if (ModelState.IsValid) { _realEstateService.UpdateRealEstateDto(real); _realEstateService.Save(); return(RedirectToAction("Index")); } return(View(real)); }