コード例 #1
0
        public void CreateEvaluation(long userId, string pubName, decimal evaluation)
        {
            long?pubId = pubRepository.GetPubByName(pubName).Id;

            if (pubId == null)
            {
                throw new NullReferenceException("Bar não cadastrado!");
            }
            userRepository.CreateEvaluation(userId, (long)pubId, evaluation);

            IEnumerable <UserPubEvaluation> userPubCollection = pubRepository.ListEvaluationById((long)pubId);
            decimal averageEvaluations = userPubCollection.Average(x => x.Evaluation);

            pubRepository.UpdateEvaluation((long)pubId, averageEvaluations);
        }
コード例 #2
0
        // public Pub GetPubByName(string pubName) => repository.GetPubByName(pubName);

        public void CreatePub(string name, string description, string address, string contact)
        {
            bool pubExist = repository.GetPubByName(name) != null;

            if (pubExist != false)
            {
                throw new Exception("Esse bar já foi cadastrado");
            }
            repository.CreatePub(name, description, address, contact);
        }