Exemplo n.º 1
0
        public void DecreaseFreqOne(int id)
        {
            Category category = new Category();

            if (id != 0)
            {
                category = _context.Category.Find(id);
                if (category.frequency != 0)
                {
                    category.frequency = category.frequency - 1;
                }

                _context.SaveChanges();
            }
        }
Exemplo n.º 2
0
 public void Add(Comment comment)
 {
     context.Comment.Add(comment);
     context.SaveChanges();
 }
Exemplo n.º 3
0
 public void Add(Reports report)
 {
     context.Reports.Add(report);
     context.SaveChanges();
 }
Exemplo n.º 4
0
 public void Add(Logs log)
 {
     context.Logs.Add(log);
     context.SaveChanges();
 }
Exemplo n.º 5
0
        public bool Save(User addEditUser)
        {
            if (addEditUser.userId == 0)
            {
                User user = new User();

                user.firstName  = addEditUser.firstName;
                user.lastName   = addEditUser.lastName;
                user.username   = addEditUser.username;
                user.password   = addEditUser.password;
                user.createTime = DateTime.Now;
                user.updateTime = DateTime.Now;
                user.lastLogin  = DateTime.Now;
                user.questionId = addEditUser.questionId;
                user.answer     = addEditUser.answer;
                user.userType   = addEditUser.userType;
                this.context.User.Add(addEditUser);
                int result = this.context.SaveChanges();

                if (result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                User dbEntry = context.User.Find(addEditUser.userId);
                if (dbEntry != null)
                {
                    dbEntry.userId     = addEditUser.userId;
                    dbEntry.firstName  = addEditUser.firstName;
                    dbEntry.lastName   = addEditUser.lastName;
                    dbEntry.password   = addEditUser.password;
                    dbEntry.updateTime = DateTime.Now;
                    dbEntry.questionId = addEditUser.questionId;
                    dbEntry.answer     = addEditUser.answer;
                    dbEntry.userType   = addEditUser.userType;
                    dbEntry.userImage  = addEditUser.userImage;
                    dbEntry.imageSize  = addEditUser.imageSize;
                    addEditUser.userId = dbEntry.userId;
                    if (context.SaveChanges() > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                return(true);
            }
        }
Exemplo n.º 6
0
 public void Add(Post post)
 {
     context.Post.Add(post);
     context.SaveChanges();
 }