Example #1
0
 public Message GetMessageByUserType(int userId, Enum.MessageType type)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Messages.FirstOrDefault(m => m.UserId == userId && m.Type == (int)type));
     }
 }
Example #2
0
 public List <Donation> GetAllDonation()
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Donations.ToList());
     }
 }
Example #3
0
 public User GetUser(int userId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Users.Find(userId));
     }
 }
Example #4
0
 public List <ChallegeDay> GetChallengeDayByUser(int userId, int challengeId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.ChallegeDays.Where(c => c.UserId == userId && c.ChallengeId == challengeId).ToList());
     }
 }
Example #5
0
 public Challenge GetChallenge(int challengeId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Challenges.Include(c => c.User.Socials).Include(c => c.Donation).Include(cl => cl.ChallegeDays).Where(cl => cl.Id == challengeId).FirstOrDefault());
     }
 }
Example #6
0
 public List <Challenge> GetBatchActiveChallengeByPage(int pageIndex, int size)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Challenges.OrderBy(c => c.StartTime).Include(c => c.Donation).Include(cl => cl.ChallegeDays).Include(c => c.User.Socials).Where(c => c.isActive == true).Skip((pageIndex - 1) * size).Take(size).ToList());
     }
 }
Example #7
0
 public List <Challenge> GetAllActiveChallenge()
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Challenges.Where(c => c.isActive == true).ToList());
     }
 }
Example #8
0
 public Message GetMessage(int messageId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Messages.Find(messageId));
     }
 }
Example #9
0
 public Message GetDefaultWasteMessage()
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Messages.FirstOrDefault(m => m.ChallengeId == null && m.UserId == null && m.Type == (int)MessageType.Waste));
     }
 }
Example #10
0
 public List <Message> GetMessagesByChallegen(int challengId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Messages.Where(m => m.ChallengeId == challengId).ToList());
     }
 }
Example #11
0
 public bool AddMessage(Message message)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var rs = entity.Messages.Add(message);
         entity.SaveChanges();
         return(rs != null);
     }
 }
Example #12
0
 public bool AddChallengeDay(ChallegeDay challengeDay)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var rs = entity.ChallegeDays.Add(challengeDay);
         entity.SaveChanges();
         return(rs != null);
     }
 }
Example #13
0
 public bool AddDonation(Donation donation)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var rs = entity.Donations.Add(donation);
         entity.SaveChanges();
         return(rs != null);
     }
 }
Example #14
0
File: WoWCore.cs Project: duylt/wow
 public bool AddUser(User user)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var rs = entity.Users.Add(user);
         entity.SaveChanges();
         return rs != null;
     }
 }
Example #15
0
File: WoWCore.cs Project: duylt/wow
 public void CompletedChallenge(int challengeId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var completedChallenge = entity.Challenges.Find(challengeId);
         completedChallenge.isActive = false;
         entity.SaveChanges();
     }
 }
Example #16
0
File: WoWCore.cs Project: duylt/wow
 public bool AddDonation(Donation donation)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var rs = entity.Donations.Add(donation);
         entity.SaveChanges();
         return rs != null;
     }
 }
Example #17
0
File: WoWCore.cs Project: duylt/wow
 public bool AddMessage(Message message)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var rs = entity.Messages.Add(message);
         entity.SaveChanges();
         return rs != null;
     }
 }
Example #18
0
File: WoWCore.cs Project: duylt/wow
 public bool AddChallengeDay(ChallegeDay challengeDay)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var rs = entity.ChallegeDays.Add(challengeDay);
         entity.SaveChanges();
         return rs != null;
     }
 }
Example #19
0
 public void CompletedChallenge(int challengeId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var completedChallenge = entity.Challenges.Find(challengeId);
         completedChallenge.isActive = false;
         entity.SaveChanges();
     }
 }
Example #20
0
 public bool AddUser(User user)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var rs = entity.Users.Add(user);
         entity.SaveChanges();
         return(rs != null);
     }
 }
Example #21
0
 public User GetUserByClientId(string clientId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var social = entity.Socials.Include(s => s.User).FirstOrDefault(s => s.ClientId_.Equals(clientId));
         if (social != null)
         {
             return(entity.Users.Include(u => u.Socials).FirstOrDefault(u => u.Id == social.UserId));
         }
         return(null);
     }
 }
Example #22
0
 public bool UpdateChallengeDay(ChallegeDay challengeDay)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         var coreValue = entity.ChallegeDays.FirstOrDefault(c => c.Id == challengeDay.Id);
         if (coreValue != null)
         {
             coreValue.IsProcessed = challengeDay.IsProcessed;
         }
         entity.SaveChanges();
         return(true);
     }
 }
Example #23
0
 public bool RemoveMessage(int messageId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var message = entity.Messages.Find(messageId);
         if (message != null)
         {
             var rs = entity.Messages.Remove(message);
             entity.SaveChanges();
             return(rs != null);
         }
         return(false);
     }
 }
Example #24
0
 public bool RemoveDonation(int donationId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var donation = entity.Donations.Find(donationId);
         if (donation != null)
         {
             var rs = entity.Donations.Remove(donation);
             entity.SaveChanges();
             return(rs != null);
         }
         return(false);
     }
 }
Example #25
0
 public bool UpdateSocialToken(int socialId, string token)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var social = entity.Socials.Find(socialId);
         if (social != null)
         {
             social.Token = token;
             entity.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Example #26
0
 public bool RemoveUser(int userId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var user = entity.Users.Find(userId);
         if (user != null)
         {
             var rs = entity.Users.Remove(user);
             entity.SaveChanges();
             return(rs != null);
         }
         return(false);
     }
 }
Example #27
0
 public bool UpdateUser(User user)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var userToUpdated = entity.Users.FirstOrDefault(u => u.Id == user.Id);
         if (userToUpdated != null)
         {
             userToUpdated.Name     = user.Name;
             userToUpdated.ImageUrl = user.ImageUrl;
             entity.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Example #28
0
        public Challenge GetActiveChallengeByUserId(int userId)
        {
            using (var entity = new WakeOrWasteEntities())
            {
                entity.Configuration.ProxyCreationEnabled = false;
                var challenge = entity.Challenges.Include(cl => cl.ChallegeDays).Include(c => c.Donation).FirstOrDefault(c => c.UserId == userId && c.isActive == true);
                //Remove the circle
                if (challenge != null)
                {
                    foreach (var item in challenge.ChallegeDays)
                    {
                        item.Challenge = null;
                    }

                    if (challenge.Donation != null)
                    {
                        challenge.Donation.Challenges = null;
                    }
                }

                return(challenge);
            }
        }
Example #29
0
File: WoWCore.cs Project: duylt/wow
 public User GetUser(int userId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Users.Find(userId);
     }
 }
Example #30
0
File: WoWCore.cs Project: duylt/wow
 public bool RemoveUser(int userId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var user = entity.Users.Find(userId);
         if (user != null)
         {
             var rs = entity.Users.Remove(user);
             entity.SaveChanges();
             return rs != null;
         }
         return false;
     }
 }
Example #31
0
File: WoWCore.cs Project: duylt/wow
 public Challenge GetChallenge(int challengeId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Challenges.Include(c => c.User.Socials).Include(c => c.Donation).Include(cl => cl.ChallegeDays).Where(cl => cl.Id == challengeId).FirstOrDefault();
     }
 }
Example #32
0
File: WoWCore.cs Project: duylt/wow
 public List<ChallegeDay> GetChallengeDayByUser(int userId, int challengeId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.ChallegeDays.Where(c => c.UserId == userId && c.ChallengeId == challengeId).ToList();
     }
 }
Example #33
0
File: WoWCore.cs Project: duylt/wow
 public bool UpdateChallengeDay(ChallegeDay challengeDay)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         var coreValue = entity.ChallegeDays.FirstOrDefault(c => c.Id == challengeDay.Id);
         if (coreValue != null)
         {
             coreValue.IsProcessed = challengeDay.IsProcessed;
         }
         entity.SaveChanges();
         return true;
     }
 }
Example #34
0
File: WoWCore.cs Project: duylt/wow
 public bool UpdateSocialToken(int socialId, string token)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var social = entity.Socials.Find(socialId);
         if (social != null)
         {
             social.Token = token;
             entity.SaveChanges();
             return true;
         }
         return false;
     }
 }
Example #35
0
File: WoWCore.cs Project: duylt/wow
 public Message GetDefaultWasteMessage()
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Messages.FirstOrDefault(m => m.ChallengeId == null && m.UserId == null && m.Type == (int)MessageType.Waste);
     }
 }
Example #36
0
File: WoWCore.cs Project: duylt/wow
        public Challenge GetActiveChallengeByUserId(int userId)
        {
            using (var entity = new WakeOrWasteEntities())
            {
                entity.Configuration.ProxyCreationEnabled = false;
                var challenge = entity.Challenges.Include(cl => cl.ChallegeDays).Include(c => c.Donation).FirstOrDefault(c => c.UserId == userId && c.isActive == true);
                //Remove the circle
                if (challenge != null)
                {
                    foreach (var item in challenge.ChallegeDays)
                    {
                        item.Challenge = null;
                    }

                    if (challenge.Donation != null)
                    {
                        challenge.Donation.Challenges = null;
                    }
                }

                return challenge;
            }
        }
Example #37
0
File: WoWCore.cs Project: duylt/wow
 public bool UpdateUser(User user)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var userToUpdated = entity.Users.FirstOrDefault(u => u.Id == user.Id);
         if (userToUpdated != null)
         {
             userToUpdated.Name = user.Name;
             userToUpdated.ImageUrl = user.ImageUrl;
             entity.SaveChanges();
             return true;
         }
         return false;
     }
 }
Example #38
0
File: WoWCore.cs Project: duylt/wow
 public Message GetMessage(int messageId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Messages.Find(messageId);
     }
 }
Example #39
0
File: WoWCore.cs Project: duylt/wow
 public List<Donation> GetAllDonation()
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Donations.ToList();
     }
 }
Example #40
0
File: WoWCore.cs Project: duylt/wow
 public User GetUserByClientId(string clientId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var social = entity.Socials.Include(s => s.User).FirstOrDefault(s => s.ClientId_.Equals(clientId));
         if (social != null)
         {
             return entity.Users.Include(u => u.Socials).FirstOrDefault(u => u.Id == social.UserId);
         }
         return null;
     }
 }
Example #41
0
File: WoWCore.cs Project: duylt/wow
 public bool RemoveMessage(int messageId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var message = entity.Messages.Find(messageId);
         if (message != null)
         {
             var rs = entity.Messages.Remove(message);
             entity.SaveChanges();
             return rs != null;
         }
         return false;
     }
 }
Example #42
0
File: WoWCore.cs Project: duylt/wow
 public List<Challenge> GetBatchActiveChallengeByPage(int pageIndex, int size)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Challenges.OrderBy(c => c.StartTime).Include(c=>c.Donation).Include(cl => cl.ChallegeDays).Include(c => c.User.Socials).Where(c => c.isActive == true).Skip((pageIndex - 1) * size).Take(size).ToList();
     }
 }
Example #43
0
File: WoWCore.cs Project: duylt/wow
 public List<Message> GetMessagesByChallegen(int challengId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Messages.Where(m => m.ChallengeId == challengId).ToList();
     }
 }
Example #44
0
File: WoWCore.cs Project: duylt/wow
 public Message GetMessageByUserType(int userId, Enum.MessageType type)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Messages.FirstOrDefault(m => m.UserId == userId && m.Type == (int)type);
     }
 }
Example #45
0
File: WoWCore.cs Project: duylt/wow
 public List<Challenge> GetAllActiveChallenge()
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Challenges.Where(c => c.isActive == true).ToList();
     }
 }
Example #46
0
File: WoWCore.cs Project: duylt/wow
 public bool RemoveDonation(int donationId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var donation = entity.Donations.Find(donationId);
         if (donation != null)
         {
             var rs = entity.Donations.Remove(donation);
             entity.SaveChanges();
             return rs != null;
         }
         return false;
     }
 }