public void Delete(int categoryId)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var deleteCategory = context.Categories.FirstOrDefault(category => category.id == categoryId);
                    if (deleteCategory == null)
                    {
                        check = true;
                    }
                    context.Categories.Remove(deleteCategory);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new CategoryException("816", ex);
            }
            finally
            {
                if (check)
                {
                    throw new UserException("813");
                }
            }
        }
        public void Update(Category category)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var categoryUpdated = context.Categories.FirstOrDefault(categoryObj => categoryObj.id == category.id);
                    if (categoryUpdated == null)
                    {
                        check = true;
                    }
                    categoryUpdated.name = category.name;
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new CategoryException("815", ex);
            }
            finally
            {
                if (check)
                {
                    throw new UserException("813");
                }
            }
        }
Exemple #3
0
        public List <CategoryOpinion> GetAllOfOpinion(int opinion_id)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    List <CategoryOpinion> categoryOpinionFound = context.CategoryOpinions.Where(categoryOpinion => categoryOpinion.Opinion_id == opinion_id).ToList();
                    if (categoryOpinionFound == null)
                    {
                        check = true;
                    }
                    return(categoryOpinionFound);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("814", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("812");
                }
            }
        }
Exemple #4
0
        public void Update(CategoryOpinion categoryOpinion)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var categoryOpinionUpdated = context.CategoryOpinions.FirstOrDefault(categoryOpinionObj => categoryOpinionObj.Id == categoryOpinion.Id);
                    if (categoryOpinionUpdated == null)
                    {
                        check = true;
                    }
                    categoryOpinionUpdated.Categ_id   = categoryOpinion.Categ_id;
                    categoryOpinionUpdated.Opinion_id = categoryOpinion.Opinion_id;

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("815", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("813");
                }
            }
        }
        public Category GetByName(string name)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var categoryFound = context.Categories.FirstOrDefault(category => category.name == name);
                    if (categoryFound == null)
                    {
                        check = true;
                    }
                    return(categoryFound);
                }
            }
            catch (Exception ex)
            {
                throw new CategoryException("814", ex);
            }
            finally
            {
                if (check)
                {
                    throw new UserException("812");
                }
            }
        }
        public void Update(OpinionVote opinionVote)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var opinionVoteUpdated = context.OpinionVotes.FirstOrDefault(opinionVoteObj => opinionVoteObj.Id == opinionVote.Id);
                    if (opinionVoteUpdated == null)
                    {
                        check = true;
                    }
                    opinionVoteUpdated.Vote_pro = opinionVote.Vote_pro;

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("815", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("813");
                }
            }
        }
        public void Update(User user)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var userUpdated = context.Users.FirstOrDefault(userObj => userObj.Email == user.Email);
                    if (userUpdated == null)
                    {
                        check = true;
                    }
                    userUpdated.Birthdate = user.Birthdate;
                    userUpdated.Password  = user.Password;
                    userUpdated.Type      = user.Type;
                    userUpdated.Username  = user.Username;
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new UserException("805", ex);
            }
            finally
            {
                if (check)
                {
                    throw new UserException("803");
                }
            }
        }
Exemple #8
0
        public Argument GetById(int argumentId)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var argumentFound = context.Arguments.FirstOrDefault(argument => argument.Id == argumentId);
                    if (argumentFound == null)
                    {
                        check = true;
                    }
                    return(argumentFound);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("814", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("812");
                }
            }
        }
Exemple #9
0
        public List <Argument> GetAll()
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var arguments = context.Arguments;
                    if (arguments.ToList().Count == 0)
                    {
                        check = true;
                    }
                    return(arguments.ToList());
                }
            }
            catch (Exception ex)
            {
                throw new Exception("811", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("812");
                }
            }
        }
Exemple #10
0
        public List <Argument> GetAllOfOpinion(int opinion_id)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    List <Argument> argumentFound = context.Arguments.Where(argument => argument.Opinion_id == opinion_id).ToList();
                    if (argumentFound == null)
                    {
                        check = true;
                    }
                    return(argumentFound);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("814", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("812");
                }
            }
        }
Exemple #11
0
        public void Delete(int argumentId)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var deleteArgument = context.Arguments.FirstOrDefault(argument => argument.Id == argumentId);
                    if (deleteArgument == null)
                    {
                        check = true;
                    }
                    context.Arguments.Remove(deleteArgument);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("816", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("813");
                }
            }
        }
        public void Delete(int opinionVoteId)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var deleteOpinionVote = context.OpinionVotes.FirstOrDefault(opinionVote => opinionVote.Id == opinionVoteId);
                    if (deleteOpinionVote == null)
                    {
                        check = true;
                    }
                    context.OpinionVotes.Remove(deleteOpinionVote);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("816", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("813");
                }
            }
        }
        public void Delete(string userEmail)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var deleteUser = context.Users.FirstOrDefault(user => user.Email == userEmail);
                    if (deleteUser == null)
                    {
                        check = true;
                    }
                    context.Users.Remove(deleteUser);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new UserException("806", ex);
            }
            finally
            {
                if (check)
                {
                    throw new UserException("803");
                }
            }
        }
Exemple #14
0
 public void Update(Content content)
 {
     try
     {
         using (var context = new dezbateriEntities())
         {
             var contentUpdated = context.Contents.FirstOrDefault(contentObj => contentObj.debate_id == content.debate_id);
             if (contentUpdated == null)
             {
                 throw new ContentException("No content found");
             }
             contentUpdated.round_1 = content.round_1;
             contentUpdated.round_2 = content.round_2;
             contentUpdated.round_3 = content.round_3;
             contentUpdated.round_4 = content.round_4;
             contentUpdated.round_5 = content.round_5;
             contentUpdated.round_6 = content.round_6;
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new ContentException("Update", ex);
     }
 }
        public List <Opinion> GetAllOfUsername(string email)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    List <Opinion> opinionFound = context.Opinions.Where(opinion => opinion.User_email == email).ToList();
                    if (opinionFound == null)
                    {
                        check = true;
                    }
                    return(opinionFound);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("814", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("812");
                }
            }
        }
        public void Update(Opinion opinion)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var opinionUpdated = context.Opinions.FirstOrDefault(opinionObj => opinionObj.Id == opinion.Id);
                    if (opinionUpdated == null)
                    {
                        check = true;
                    }
                    opinionUpdated.Subject      = opinion.Subject;
                    opinionUpdated.Date_created = opinion.Date_created;
                    opinionUpdated.User_email   = opinion.User_email;
                    opinionUpdated.Picture_url  = opinion.Picture_url;

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("815", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("813");
                }
            }
        }
        public Opinion GetById(int opinionId)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var opinionFound = context.Opinions.FirstOrDefault(opinion => opinion.Id == opinionId);
                    if (opinionFound == null)
                    {
                        check = true;
                    }
                    return(opinionFound);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("814", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("812");
                }
            }
        }
        public List <User> GetAll()
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var users = context.Users;
                    if (users.ToList().Count == 0)
                    {
                        check = true;
                    }
                    return(users.ToList());
                }
            }
            catch (Exception ex)
            {
                throw new UserException("801", ex);
            }
            finally {
                if (check)
                {
                    throw new UserException("802");
                }
            }
        }
        public User GetByEmail(string userEmail)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var userFound = context.Users.FirstOrDefault(user => user.Email == userEmail);
                    if (userFound == null)
                    {
                        check = true;
                    }
                    return(userFound);
                }
            }
            catch (Exception ex)
            {
                throw new UserException("804", ex);
            }
            finally
            {
                if (check)
                {
                    throw new UserException("803");
                }
            }
        }
Exemple #20
0
        public void Update(Argument argument)
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var argumentUpdated = context.Arguments.FirstOrDefault(argumentObj => argumentObj.Id == argument.Id);
                    if (argumentUpdated == null)
                    {
                        check = true;
                    }
                    argumentUpdated.Side         = argument.Side;
                    argumentUpdated.Date_created = argument.Date_created;
                    argumentUpdated.Content      = argument.Content;

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("815", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("813");
                }
            }
        }
        public List <OpinionVote> GetAll()
        {
            Boolean check = false;

            try
            {
                using (var context = new dezbateriEntities())
                {
                    var opinionVotes = context.OpinionVotes;
                    if (opinionVotes.ToList().Count == 0)
                    {
                        check = true;
                    }
                    return(opinionVotes.ToList());
                }
            }
            catch (Exception ex)
            {
                throw new Exception("811", ex);
            }
            finally
            {
                if (check)
                {
                    throw new Exception("812");
                }
            }
        }
 public void Add(User user)
 {
     try
     {
         using (var context = new dezbateriEntities())
         {
             context.Users.Add(user);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new UserException("800", ex);
     }
 }
Exemple #23
0
 public void Add(Content content)
 {
     try
     {
         using (var context = new dezbateriEntities())
         {
             context.Contents.Add(content);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new ContentException("Add", ex);
     }
 }
Exemple #24
0
 public void Add(CategoryOpinion categoryOpinion)
 {
     try
     {
         using (var context = new dezbateriEntities())
         {
             context.CategoryOpinions.Add(categoryOpinion);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("810", ex);
     }
 }
Exemple #25
0
 public void Add(CategoryDebate categoryDebate)
 {
     try
     {
         using (var context = new dezbateriEntities())
         {
             context.CategoryDebates.Add(categoryDebate);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new CategoryDebateException("Add", ex);
     }
 }
Exemple #26
0
 public void Add(Vote vote)
 {
     try
     {
         using (var context = new dezbateriEntities())
         {
             context.Votes.Add(vote);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new VoteException("Add", ex);
     }
 }
 public void Add(RoundState roundState)
 {
     try
     {
         using (var context = new dezbateriEntities())
         {
             context.RoundStates.Add(roundState);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new RoundStateException("Add", ex);
     }
 }
Exemple #28
0
 public void Add(Argument argument)
 {
     try
     {
         using (var context = new dezbateriEntities())
         {
             context.Arguments.Add(argument);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("810", ex);
     }
 }
Exemple #29
0
 public void Delete(int categoryDebateId)
 {
     try
     {
         using (var context = new dezbateriEntities())
         {
             context.CategoryDebates.RemoveRange(context.CategoryDebates.Where(categoryDebate => categoryDebate.debate_id == categoryDebateId));
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new CategoryDebateException("Delete", ex);
     }
 }
Exemple #30
0
 public void Add(UserDebate userDebate)
 {
     try
     {
         using (var context = new dezbateriEntities())
         {
             context.UserDebates.Add(userDebate);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new UserDebateException("Add", ex);
     }
 }