public bool AddComment(CommentDTO commentDTO)
        {
            var user = _repository.GetUserByEmail(commentDTO.UserEmail);

            if (_repository.CheckUserPriority(user, 10) == false && _repository.CheckUserPriority(user, 20) == false)
            {
                return(false);
            }

            //var attraction = _repository.GetEntityById<Attraction>(commentDTO.AttractionId);

            //if(null == attraction.Comments)
            //{
            //    attraction.Comments = new List<Comment>();
            //}

            Comment comment = new Comment()
            {
                Attraction = new Attraction()
                {
                    Id = commentDTO.AttractionId
                },
                User           = user,
                CommentContent = commentDTO.CommentContent,
            };

            _repository.AddComment(comment);

            return(true);
        }
        public bool AddAttraction(AttractionDTO attractionDTO)
        {
            User user = _repository.GetUserByEmail(attractionDTO.EmailUser);

            if (_repository.CheckUserPriority(user, 20) == false)
            {
                return(false);
            }
            AttractionType attractionType = _repository.GetAttractionTypeByTitle(attractionDTO.Title);
            Location       location       = new Location()
            {
                Address    = attractionDTO.Address,
                PostalCode = attractionDTO.PostalCode
            };

            return(_repository.AddAttraction(new Attraction()
            {
                AttractionType = attractionType,
                User = user,
                Name = attractionDTO.Name,
                Description = attractionDTO.Description,
                Rating = 0,
                PhoneNumber = attractionDTO.PhoneNumber,
                OpenTime = attractionDTO.OpenTime,
                CloseTime = attractionDTO.CloseTime,
                CreateAtractionTime = DateTime.Now,
                Location = location,
                ImagePath = @attractionDTO.Base64ToImage(attractionDTO.Image),
            }));
        }
        public bool CheckUserPriority(string email)
        {
            var x = _repository.GetUserByEmail(email);

            if (null == x)
            {
                return(false);
            }
            if (_repository.CheckUserPriority(x, 20) == true)
            {
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        public bool CheckUserPriority(string email)
        {
            var x = _repository.GetUserByEmail(email);

            return(_repository.CheckUserPriority(x, 20));
        }