コード例 #1
0
        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));
        }
コード例 #2
0
        public ActionResult Add(EditRealEstateViewModel realEstate)
        {
            RealEstateDTO real = realEstate.RealEstateDto;

            if (real.Id == 0)
            {
                _realEstateService.AddRealEstateDto(real);
                _realEstateService.Save();

                return(RedirectToAction("Index"));
            }
            return(View(real));
        }
コード例 #3
0
        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));
        }