public void UpdateRealEstate(RealEstateDTO item)
        {
            RealEstate real = new RealEstate()
            {
                Id               = item.Id,
                RealEstateID     = item.RealEstateID,
                Price            = item.Price,
                Postcode         = item.Postcode,
                Location         = item.Location,
                Bathrooms        = item.Bathrooms,
                Bedrooms         = item.Bedrooms,
                Garden           = item.Garden,
                LivingRooms      = item.LivingRooms,
                Parking          = item.Parking,
                Shower           = item.Shower,
                Tenure           = item.Tenure,
                PropertyStatus   = item.PropertyStatus,
                SSTC             = item.SSTC,
                Area             = item.Area,
                SalesCorner      = item.SalesCorner,
                ImagePath        = item.ImagePath,
                ImageMimeType    = item.ImageMimeType,
                ShortDescription = item.ShortDescription,
                LongDescription  = item.LongDescription
            };

            _testStoreContext.Entry(real).State = EntityState.Modified;
        }
        public RealEstateDTO GetLastAddRealEstate()
        {
            RealEstate real = (from u in _testStoreContext.RealEstates
                               select u).Last();
            RealEstateDTO realEstateDto = new RealEstateDTO()
            {
                Id               = real.Id,
                RealEstateID     = real.RealEstateID,
                Price            = real.Price,
                Postcode         = real.Postcode,
                Location         = real.Location,
                Bathrooms        = real.Bathrooms,
                Bedrooms         = real.Bedrooms,
                Garden           = real.Garden,
                LivingRooms      = real.LivingRooms,
                Parking          = real.Parking,
                Shower           = real.Shower,
                Tenure           = real.Tenure,
                PropertyStatus   = real.PropertyStatus,
                SSTC             = real.SSTC,
                Area             = real.Area,
                SalesCorner      = real.SalesCorner,
                ImagePath        = real.ImagePath,
                ImageMimeType    = real.ImageMimeType,
                ShortDescription = real.ShortDescription,
                LongDescription  = real.LongDescription
            };

            return(realEstateDto);
        }
        public void AddRealEstate(RealEstateDTO item)
        {
            RealEstate realEstate = new RealEstate()
            {
                RealEstateID     = item.RealEstateID,
                Price            = item.Price,
                Postcode         = item.Postcode,
                Location         = item.Location,
                Bathrooms        = item.Bathrooms,
                Bedrooms         = item.Bedrooms,
                Garden           = item.Garden,
                LivingRooms      = item.LivingRooms,
                Parking          = item.Parking,
                Shower           = item.Shower,
                Tenure           = item.Tenure,
                PropertyStatus   = item.PropertyStatus,
                SSTC             = item.SSTC,
                Area             = item.Area,
                SalesCorner      = item.SalesCorner,
                ShortDescription = item.ShortDescription,
                LongDescription  = item.LongDescription
            };

            _testStoreContext.RealEstates.Add(realEstate);
        }
        public RealEstateDTO GetRealEstateById(int id)
        {
            var           realEstate    = _testStoreContext.RealEstates.Find(id);
            RealEstateDTO realEstateDto = new RealEstateDTO()
            {
                Id               = realEstate.Id,
                RealEstateID     = realEstate.RealEstateID,
                Price            = realEstate.Price,
                Postcode         = realEstate.Postcode,
                Location         = realEstate.Location,
                Bathrooms        = realEstate.Bathrooms,
                Bedrooms         = realEstate.Bedrooms,
                Garden           = realEstate.Garden,
                LivingRooms      = realEstate.LivingRooms,
                Parking          = realEstate.Parking,
                Shower           = realEstate.Shower,
                Tenure           = realEstate.Tenure,
                PropertyStatus   = realEstate.PropertyStatus,
                SSTC             = realEstate.SSTC,
                Area             = realEstate.Area,
                SalesCorner      = realEstate.SalesCorner,
                ImagePath        = realEstate.ImagePath,
                ImageMimeType    = realEstate.ImageMimeType,
                ShortDescription = realEstate.ShortDescription,
                LongDescription  = realEstate.LongDescription
            };

            return(realEstateDto);
        }
        public async Task <OperationDetails> UpdateRealEstateAsync(RealEstateDTO realEstateDto, OperationDetails MessageSuccess, OperationDetails MessageFail)
        {
            int idRealEstate = realEstateDto.RealEstateID;

            return(await service.UpdateItemAsync(realEstateDto,
                                                 idRealEstate,
                                                 MessageSuccess,
                                                 MessageFail));
        }
Example #6
0
 public RealEstateViewDTO() : base()
 {
     RealEstate         = new RealEstateDTO();
     RealEstateClass    = new RealEstateClassDTO();
     RealEstateStatus   = new RealEstateStatusDTO();
     RealEstateType     = new RealEstateTypeDTO();
     RealEstateTypeWall = new RealEstateTypeWallDTO();
     AddressView        = new AddressViewDTO();
 }
Example #7
0
        public async Task Create(RealEstateDTO realEstateDTO, string realtorId)
        {
            var realEstate = _mapper.Map <RealEstateDTO, RealEstate>(realEstateDTO);

            realEstate.Id           = new RealEstate().Id;
            realEstate.RealtorId    = realtorId;
            realEstate.IsSold       = false;
            realEstate.CreationDate = DateTime.Now;
            _unitOfWork.RealEstates.Create(realEstate);
            await _unitOfWork.SaveAsync();
        }
Example #8
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));
        }
Example #9
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));
        }
        public object LeaseOut([FromBody] RealEstateDTO leaseOutModel)
        {
            RealEstate realEstate = null;

            if (ModelState.IsValid)
            {
                realEstate = new RealEstate(leaseOutModel.type, leaseOutModel.name);

                _service.Add(realEstate);
            }

            return(realEstate);
        }
Example #11
0
        public async Task Save(RealEstateDTO realEstateDTO)
        {
            var realEstate       = _mapper.Map <RealEstateDTO, RealEstate>(realEstateDTO);
            var originRealEstate = await _unitOfWork.RealEstates.GetByIdAsync(realEstate.Id);

            if (originRealEstate == null)
            {
                throw new HttpException(404, "Cannot find real estate with id = " + realEstate.Id);
            }
            realEstate.RealtorId    = originRealEstate.RealtorId;
            realEstate.CreationDate = originRealEstate.CreationDate;
            _unitOfWork.RealEstates.Update(realEstate);
            await _unitOfWork.SaveAsync();
        }
Example #12
0
 public void AddImage(int id, string imagePath, string imageMimeType)
 {
     if (id != 0)
     {
         _realEstateService.AddImage(id, imagePath, imageMimeType);
     }
     else
     {
         var realEstateDto = new RealEstateDTO();
         realEstateDto.ImagePath     = imagePath;
         realEstateDto.ImageMimeType = imageMimeType;
         _realEstateService.AddRealEstateDto(realEstateDto);
         _realEstateService.Save();
     }
 }
Example #13
0
        public FilePathResult GetImage(int id)
        {
            RealEstateDTO real = _realEstateService.GetRealEstateById(id);

            if (real.ImagePath != null)
            {
                string fullpath = Server.MapPath(real.ImagePath);
                ViewBag.ImagePath = fullpath;
                return(File(real.ImagePath, real.ImageMimeType));
            }
            else
            {
                return(null);
            }
        }
Example #14
0
        public ActionResult Particulars(int id)
        {
            RealEstateDTO real = _realEstateService.GetRealEstateById(id);

            DescriptionDTO description = _descriptionService.GetDescriptionByIdRealEstate(real.Id);

            if (description == null)
            {
                _descriptionService.AddDescriptionDto(real.Id);
                _descriptionService.Save();
                description = _descriptionService.GetDescriptionByIdRealEstate(real.Id);
            }

            var photos = new List <PhotoForGalleryDTO>();
            int count  = 0;

            foreach (var item in _descriptionService.GetPhotoForGalleryById(id).ToList())
            {
                if (count < 4)
                {
                    photos.Add(new PhotoForGalleryDTO()
                    {
                        RealEstateId = item.RealEstateId,
                        UrlImage     = item.UrlImage,
                    });
                    count++;
                }
                else
                {
                    break;
                }
            }

            var model = new DescriptionViewModel()
            {
                Id                 = description.Id,
                Price              = real.Price,
                Tenure             = real.Tenure,
                Location           = real.Location,
                RealEstateId       = description.RealEstateId,
                ShortDescription   = description.ShortDescription,
                LongDescription    = description.LongDescription,
                PhotoForGalleryDto = photos
            };

            ViewBag.LongDescription = description.LongDescription;
            return(View(model));
        }
Example #15
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));
        }
Example #16
0
        public ActionResult Delete(int id)
        {
            RealEstateDTO realEstate = _realEstateService.GetRealEstateById(id);

            return(View(realEstate));
        }
Example #17
0
 public void AddRealEstateDto(RealEstateDTO realEstateDto)
 {
     _realEstateRepository.AddRealEstate(realEstateDto);
 }
 public async Task <ResponsePackage <RealEstateDTO> > UpdateRealEstateRecord(RealEstateDTO realEstate)
 {
     return(await new SendToServerService <RealEstateDTO, RealEstateDTO>().PostDataByJsonObjectAsync("RealEstate/UpdateRealEstate", realEstate));
 }
Example #19
0
 public void UpdateRealEstateDto(RealEstateDTO realEstateDto)
 {
     _realEstateRepository.UpdateRealEstate(realEstateDto);
 }
Example #20
0
 public async Task <OperationDetails> UpdateRealEstate(RealEstateDTO RealEstateDto)
 {
     return(await realEstateService.UpdateRealEstateAsync(RealEstateDto,
                                                          new RealEstateMessageSpecification().ToSuccessUpdateMessage(),
                                                          new RealEstateMessageSpecification().ToFailUpdateMessage()));
 }
Example #21
0
 public RealEstateMessageSpecification(RealEstateDTO realEstateDto = null)
 {
     RealEstateDto = realEstateDto;
 }