Exemplo n.º 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));
     }
 }
Exemplo n.º 2
0
 public List <Donation> GetAllDonation()
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Donations.ToList());
     }
 }
Exemplo n.º 3
0
 public User GetUser(int userId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Users.Find(userId));
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 7
0
 public List <Challenge> GetAllActiveChallenge()
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Challenges.Where(c => c.isActive == true).ToList());
     }
 }
Exemplo n.º 8
0
 public Message GetMessage(int messageId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return(entity.Messages.Find(messageId));
     }
 }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 14
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }
Exemplo n.º 15
0
Arquivo: WoWCore.cs Projeto: 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();
     }
 }
Exemplo n.º 16
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }
Exemplo n.º 17
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }
Exemplo n.º 18
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 29
0
Arquivo: WoWCore.cs Projeto: duylt/wow
 public User GetUser(int userId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Users.Find(userId);
     }
 }
Exemplo n.º 30
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }
Exemplo n.º 31
0
Arquivo: WoWCore.cs Projeto: 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();
     }
 }
Exemplo n.º 32
0
Arquivo: WoWCore.cs Projeto: 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();
     }
 }
Exemplo n.º 33
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }
Exemplo n.º 34
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }
Exemplo n.º 35
0
Arquivo: WoWCore.cs Projeto: 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);
     }
 }
Exemplo n.º 36
0
Arquivo: WoWCore.cs Projeto: 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;
            }
        }
Exemplo n.º 37
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }
Exemplo n.º 38
0
Arquivo: WoWCore.cs Projeto: duylt/wow
 public Message GetMessage(int messageId)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Messages.Find(messageId);
     }
 }
Exemplo n.º 39
0
Arquivo: WoWCore.cs Projeto: duylt/wow
 public List<Donation> GetAllDonation()
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Donations.ToList();
     }
 }
Exemplo n.º 40
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }
Exemplo n.º 41
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }
Exemplo n.º 42
0
Arquivo: WoWCore.cs Projeto: 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();
     }
 }
Exemplo n.º 43
0
Arquivo: WoWCore.cs Projeto: 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();
     }
 }
Exemplo n.º 44
0
Arquivo: WoWCore.cs Projeto: 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);
     }
 }
Exemplo n.º 45
0
Arquivo: WoWCore.cs Projeto: duylt/wow
 public List<Challenge> GetAllActiveChallenge()
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         return entity.Challenges.Where(c => c.isActive == true).ToList();
     }
 }
Exemplo n.º 46
0
Arquivo: WoWCore.cs Projeto: 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;
     }
 }