Exemplo n.º 1
0
        public ResidenceModel GetResidence(int residenceId)
        {
            var entity = _iResidenceDAO.GetResidence(residenceId);
            var model  = ResidenceConverter.EntityToModel(entity);

            return(model);
        }
Exemplo n.º 2
0
        public List <ResidenceModel> GetResidencesSkip(int toSkipNumber)
        {
            var entities = _iResidenceDAO.GetResidencesSkip(toSkipNumber);
            var model    = ResidenceConverter.EntitiesToModels(entities);

            return(model);
        }
Exemplo n.º 3
0
        public List <ResidenceModel> GetMyResidences(int userId, int residencesPageNumber)
        {
            if (residencesPageNumber < 0)
            {
                residencesPageNumber = 0;
            }

            var entities = _iResidenceDAO.GetMyResidences(userId, residencesPageNumber);
            var models   = ResidenceConverter.EntitiesToModels(entities);

            return(models);
        }
Exemplo n.º 4
0
        public bool CreateResidence(ResidenceModel model)
        {
            var entity = ResidenceConverter.ModelToEntity(model);

            if (model.Images == null)
            {
                ResidenceImage residenceImage = new ResidenceImage()
                {
                    ResidenceId = entity.Id,
                    ImageName   = "https://i.imgur.com/vd8iZDs.jpg"
                };

                entity.ResidenceImages.Add(residenceImage);
            }

            return(_iResidenceDAO.CreateResidence(entity));
        }
Exemplo n.º 5
0
        public bool UpdateResidence(ResidenceModel model)
        {
            var entity = _iResidenceDAO.GetResidence(model.Id);

            entity.Name  = model.Name;
            entity.Price = model.Price;
            ResidenceConverter.AddressModelToEntity(model, entity);

            if (model.Images != null)
            {
                entity.ResidenceImages = new List <ResidenceImage>();
                ResidenceConverter.ImagesModelToEntity(model, entity);
            }

            entity.ResidenceCategories = new List <ResidenceCategory>();
            ResidenceConverter.CategoriesModelToEntity(model, entity);

            return(_iResidenceDAO.UpdateResidence(entity));
        }
Exemplo n.º 6
0
        public List <ResidenceModel> GetResidencesFiltered(string name, int minPrice, int?maxPrice)
        {
            var entities = _iResidenceDAO.GetResidencesFiltered(name, minPrice, maxPrice);

            return(ResidenceConverter.EntitiesToModels(entities));
        }