Exemplo n.º 1
0
        /// <summary>Gets the path on the hard disk to an image.</summary>
        /// <param name="unit">The unit.</param>
        /// <param name="pathToUploadedFiles">The path to uploaded files.</param>
        /// <returns>The path to an image.</returns>
        public string GetImage(Unit unit, string pathToUploadedFiles)
        {
            var userName = unit.Vendor.User.Login;

            var pathToUsersDirectory = Path.Combine(pathToUploadedFiles, userName);

            if (!Directory.Exists(pathToUsersDirectory))
                return null;

            var file = string.IsNullOrEmpty(unit.Image)
                ? string.Format("/Content/Images/no-image.png")
                : string.Format("/files/{0}/{1}", userName, unit.Image);

            return file;
        }
Exemplo n.º 2
0
        /// <summary>Maps the view data.</summary>
        /// <param name="unit">The unit.</param>
        /// <returns>Mapped model for the view.</returns>
        private ShowEstateModel MapViewData(Unit unit)
        {
            var model = new ShowEstateModel();

            Mapper.Map(unit, model);

            var coordinates = this.unitFinder.GetCoordinatesObject(unit);
            model.Latitude = coordinates.Item1;
            model.Longitude = coordinates.Item2;

            model.Email = unit.Vendor.Email;
            model.Name = unit.Vendor.Name;
            model.Rating = unit.Vendor.Rating;

            model.State = unit.GetAddress().State;
            model.City = unit.GetAddress().City;
            model.LineOne = unit.GetAddress().LineOne;
            model.LineTwo = unit.GetAddress().LineTwo;
            model.Zip = unit.GetAddress().Zip;

            model.ImagePath = this.imageService.GetImage(unit, Server.MapPath(PATH_TO_UPLOADED_FILES));

            return model;
        }
Exemplo n.º 3
0
        /// <summary>Maps the model to entity.</summary>
        /// <param name="model">The model.</param>
        /// <returns>Mapped entity.</returns>
        private Unit MapModel(CreateEstateModel model)
        {
            var unit = new Unit();
            var address = new Address();

            Mapper.Map<CreateEstateModel, Unit>(model, unit);
            Mapper.Map<CreateEstateModel, Address>(model, address);

            unit.SetAddress(address);

            return unit;
        }