/* UsersBlocked*/


        //public bool Block(UsersBlocked ub)//חסימת משתמש
        //{
        //  try
        //  {
        //    using (TakeABowDBEntities db = new TakeABowDBEntities())
        //    {

        //        if (db.UsersBlockeds.First(u => u.UserId == ub.UserId && u.BlockedUserId == ub.BlockedUserId)==null)//בדיקה אם המשתמש נחסם בעבר ע"י החוסם
        //        {
        //            db.UsersBlockeds.Add(ub);//אם לא קיים אז תוסיף
        //            db.SaveChanges();
        //            return true;
        //        }
        //        else
        //        {//אם קיים אז תשנה אותו לחסום
        //            UsersBlocked ub2 = db.UsersBlockeds.FirstOrDefault(u => u.UserId == ub.UserId && u.BlockedUserId == u.BlockedUserId);
        //            ub2.IsBlocked = true;
        //             db.SaveChanges();
        //             return true;
        //        }
        //        return false;
        //    }

        //  }
        //    catch (Exception ex)
        //    {
        //        throw;
        //    }
        //}


        public bool Block(UsersBlocked ub)//חסימת משתמש
        {
            try
            {
                using (TakeABowDBEntities db = new TakeABowDBEntities())
                {
                    var user = db.UsersBlockeds.FirstOrDefault(u => u.UserId == ub.UserId && u.BlockedUserId == ub.BlockedUserId);
                    if (user != null)
                    {
                        user.IsBlocked = !user.IsBlocked;
                        db.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        db.UsersBlockeds.Add(ub);
                        db.SaveChanges();
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                // return false;
                throw;
            }
        }
Exemplo n.º 2
0
 public User GetUserById(int userId)
 {
     using (TakeABowDBEntities db = new TakeABowDBEntities())
     {
         return(db.Users.FirstOrDefault(u => u.Id == userId));
     }
 }
 public bool updateUser(User u)
 {
     try
     {
         using (TakeABowDBEntities db = new TakeABowDBEntities())
         {
             var userDb = db.Users.First(x => x.Id == u.Id);
             if (u.Is_Deleted == true)
             {
                 userDb.Is_Deleted = true;
             }
             else
             {
                 userDb.FirstName  = u.FirstName;
                 userDb.LastName   = u.LastName;
                 userDb.Phone      = u.Phone;
                 userDb.Job        = u.Job;
                 userDb.Is_Deleted = u.Is_Deleted;
                 userDb.Password   = u.Password;
             }
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         //return false;
         throw;
     }
 }
 /*Feedbacks*/
 public bool saveNewFeedback(int sendTo, Feedback f)
 {
     try
     {
         using (TakeABowDBEntities db = new TakeABowDBEntities())
         {
             var user = db.Users.FirstOrDefault(f1 => f1.Id == sendTo);
             // var feedback = db.Feedbacks.Where(f1 => f1.UserBlocked.IsBlocked==false );//לעשות 2 תנאים ליצירת פידבק
             if (user == null)//בדיקה אם המייל קיים משהו עם כזה מייל או ידי
             {
                 return(false);
             }
             else//אם קיים
             {
                 f.ToUserId = user.Id;    //מוסיף באוביקט פידבק למי שלח
                 db.Feedbacks.Add(f);
                 db.SaveChanges();
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         throw;
         return(false);
     }
 }
Exemplo n.º 5
0
 public int getAmountViewRequests(int userId)
 {
     using (TakeABowDBEntities db = new TakeABowDBEntities())
     {
         var count = db.Permissions.Where(p => p.UserId == userId).Count(p => p.IsAllow == null);
         return(count);
     }
 }
Exemplo n.º 6
0
 public int getAmountFeedbacks(int userId)
 {
     using (TakeABowDBEntities db = new TakeABowDBEntities())
     {
         var count = db.Feedbacks.Where(f => f.ToUserId == userId).Count(f => f.IsSeen == false);
         return(count);
     }
 }
Exemplo n.º 7
0
 public List <Feedback> GetListfeedbackByUser(int id)
 {
     using (TakeABowDBEntities db = new TakeABowDBEntities())
     {
         List <Feedback> allFeedbacks = new List <Feedback>();
         allFeedbacks = db.Feedbacks.Include(f => f.User).Include(f => f.User1).Where(f => f.FromUserId == id).OrderByDescending(f => f.CreateDate).ToList();
         return(allFeedbacks);
     }
 }
Exemplo n.º 8
0
 public List <Feedback> ViewAllFeedbacks(int id)
 {
     using (TakeABowDBEntities db = new TakeABowDBEntities())
     {
         List <Feedback> allFeedbacks = new List <Feedback>();
         allFeedbacks = db.Feedbacks.Include(f => f.User).Include(f => f.User1).Where(f => f.ToUserId == id && f.IsDeleted == false).ToList();
         return(allFeedbacks);
     }
 }
Exemplo n.º 9
0
 public List <Permission> getlistInvitation(int WatchUserId)
 {
     using (TakeABowDBEntities db = new TakeABowDBEntities())
     {
         List <Permission> allPermission = new List <Permission>();
         allPermission = db.Permissions.Include(f => f.User).Where(p1 => p1.WatchUserId == WatchUserId && p1.ExpireDate > (DateTime.Now)).ToList();
         return(allPermission);
     }
 }
Exemplo n.º 10
0
 public List <Feedback> getFeedbackTop(int userId)
 {
     using (TakeABowDBEntities db = new TakeABowDBEntities())
     {
         List <Feedback> allFeedbacks = new List <Feedback>();
         allFeedbacks = db.Feedbacks.Include(f => f.User).Include(f => f.User1).Where((f => f.ToUserId == userId && f.IsSeen == true && f.IsDeleted == false)).ToList();
         return(allFeedbacks);
     }
 }
Exemplo n.º 11
0
 public List <Permission> getAllPermissions(int toPermission)
 {
     using (TakeABowDBEntities db = new TakeABowDBEntities())
     {
         List <Permission> allPermission = new List <Permission>();
         allPermission = db.Permissions.Include(f => f.User).Where(p1 => p1.UserId == toPermission && p1.IsAllow != true).OrderByDescending(p1 => p1.CreateDate).ToList();
         return(allPermission);
     }
 }
Exemplo n.º 12
0
 public bool checkUserBlock(int myId, int userId)
 {
     using (TakeABowDBEntities db = new TakeABowDBEntities())
     {
         var ub = db.UsersBlockeds.FirstOrDefault(u => u.UserId == myId && u.BlockedUserId == userId);//בודק לפי היד של הבקשה אם הוא חסום, אם חסום מחזיר אמת
         if (ub != null && ub.IsBlocked == true)
         {
             return(true);
         }
         return(false);
     }
 }
Exemplo n.º 13
0
        internal bool?checkUserAllow(int myId, int userId)
        {
            using (TakeABowDBEntities db = new TakeABowDBEntities())
            {
                var ub = db.Permissions.FirstOrDefault(u => u.UserId == userId && u.WatchUserId == myId);//בודק לפי היד של הבקשה אם הוא חסום, אם חסום מחזיר אמת

                if (ub == null)
                {
                    return(null);
                }
                else
                {
                    return(false);
                }
            }
        }
Exemplo n.º 14
0
 public List <User> GetListUsers(int userId)
 {
     try
     {
         using (TakeABowDBEntities db = new TakeABowDBEntities())
         {
             List <User> users = new List <User>();
             users = db.Users.Include(f => f.Feedbacks).Where(u => u.Is_Deleted == false && u.Id != userId).OrderBy(u => u.Id).ToList();
             return(users);
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemplo n.º 15
0
 public bool OpenUser(UsersBlocked ub)
 {
     try
     {
         using (TakeABowDBEntities db = new TakeABowDBEntities())
         {
             UsersBlocked ub2 = db.UsersBlockeds.FirstOrDefault(u => u.UserId == ub.UserId && u.BlockedUserId == u.BlockedUserId);
             ub2.IsBlocked = false;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemplo n.º 16
0
 public bool readFeedback(int idFeedback, int FromUserId)
 {
     try
     {
         using (TakeABowDBEntities db = new TakeABowDBEntities())
         {
             var feedbackDb = db.Feedbacks.First(f => f.Id == idFeedback);
             feedbackDb.IsSeen = true;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         //return false;
         throw;
     }
 }
Exemplo n.º 17
0
 public bool IsAllowPermission(int time, Permissions p)
 {
     try
     {
         using (TakeABowDBEntities db = new TakeABowDBEntities())
         {
             var p1 = db.Permissions.First(per => per.ID == p.Id);
             p1.IsAllow    = p.IsAllow;
             p1.ExpireDate = DateTime.Today.AddDays(time);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         //return false;
         throw;
     }
 }
Exemplo n.º 18
0
 /*Permission*/
 public bool AddPermission(Common.Permissions p)
 {
     using (TakeABowDBEntities db = new TakeABowDBEntities())
     {
         try
         {
             if (db.Permissions.FirstOrDefault(per => per.UserId == p.UserId && per.WatchUserId == p.WatchUserId) == null)//בדיקה אם שלח בקשת צפיה למשתמש הזה
             {
                 data.Permissions.Add(Converters.ConvertToDal.Permissions(p));
                 data.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception ex)
         {
             throw;
             //return false;
         }
     }
 }