Beispiel #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();
            }
        }
 public void Add(Comment comment)
 {
     context.Comment.Add(comment);
     context.SaveChanges();
 }
 public void Add(Reports report)
 {
     context.Reports.Add(report);
     context.SaveChanges();
 }
Beispiel #4
0
 public void Add(Logs log)
 {
     context.Logs.Add(log);
     context.SaveChanges();
 }
Beispiel #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);
            }
        }
Beispiel #6
0
 public void Add(Post post)
 {
     context.Post.Add(post);
     context.SaveChanges();
 }