Beispiel #1
0
        public ICollection<UnitWrapper> GetRecommendedUnits(UserWrapper user, int RecommendationCount)
        {
            int _numberOfDisplayedUnits = RecommendationCount <0 ? _maxNumberOfDisplayedUnits : RecommendationCount;

            UnitAccess access = new UnitAccess();
            ICollection<UnitWrapper> candidates;

            if (user == null)
            {
                candidates = access.GetUnits().ToList();
            }
            else
            {

                candidates = access.GetUnitsByDicipline(user.Dicipline.ToList()).ToList();
                if (candidates.Count() < _numberOfDisplayedUnits)
                {
                    int num = _numberOfDisplayedUnits - candidates.Count();

                    foreach (var unitWrapper in access.GetUnits().OrderByDescending(d=>d.AverageRating).Take(num))
                    {
                        candidates.Add(unitWrapper);
                    }
                }
            }

            return candidates.OrderByDescending(d => d.AverageRating).ToList().GetRange(0, candidates.Count() >= _numberOfDisplayedUnits ? _numberOfDisplayedUnits : candidates.Count());
        }
        public int GetNumberOfUnreadNotifications(UserWrapper userWrapper)
        {
            NotificationTableAdapter adapter=new NotificationTableAdapter();
            Debug.WriteLine(userWrapper.UserName);
            Object obj=adapter.Notification_GetUnreadNotificationCount(userWrapper.UserName);

            return (int) obj;
        }
        public ICollection<NotificationWrapper> GetNotificationsForUserAfterTime(UserWrapper user, DateTime time)
        {
            //if (user == null)
            //{
            //    return new List<ResponseNotificationWrapper>();
            //}

            //var notificationAccess = ObjectFactory.GetInstance<NotificationAccess>();
            //var result = notificationAccess.GetNotificationsForUserAfterTime(user, time);

            //return GetWrappedNotifications(result);
            throw new NotImplementedException();
        }
        public ICollection<NotificationWrapper> GetNotificationsForUser(UserWrapper user, int numberOfVisibleNotifications)
        {
            if (user == null)
            {
                return new List<NotificationWrapper>();
            }

            var notificationAccess = new NotificationAccess();
            var result = notificationAccess.GetNotificationsForUser(user);

            if (numberOfVisibleNotifications < 0)
            {
                return result.ToList();
            }
            return result.Take(numberOfVisibleNotifications).ToList();
        }
Beispiel #5
0
        public void UpdateUser(UserWrapper wrapper)
        {
            //MembershipUser user = Membership.GetUser(wrapper.UserName);

            //Guid id = (Guid)user.ProviderUserKey;

            //wrapper.Role = "User";
            //wrapper.BirthDate = DateTime.Now;
            //wrapper.UserID = id;
            //UserWrapper w = GetUser(wrapper.UserName);
            //wrapper.Password = w.Password;
            //wrapper.Salt = w.Salt;

            //UserAccess ua = ObjectFactory.GetInstance<UserAccess>();

            //ua.UpdateUser(wrapper);
            throw new NotImplementedException();
        }
        public IEnumerable<NotificationWrapper> GetNotificationsForUser(UserWrapper user)
        {
            NotificationTableAdapter adapter = new NotificationTableAdapter();
            DBDataSet.NotificationDataTable res = adapter.GetData(user.UserID);

            return res.Select(not => new NotificationWrapper()
                {
                    UserID = not.UserID,
                    UnitCode = not.UnitCode,
                    Comment = not.Comment,
                    FirstName = not.FirstName,
                    IsRead = not.IsRead,
                    LastName = not.LastName,
                    Rating = not.Rating,
                    ResponseId = not.ResponseId,
                    Time = not.Time
                });
        }
Beispiel #7
0
        public UserWrapper CreateUser(UserWrapper wrapper, out CreateUserStatus status)
        {
            validateUser(wrapper, out status);
            if (status == CreateUserStatus.UserValidated)
            {
                wrapper.Salt = PasswordUtilities.GenerateSalt();
                wrapper.Password = PasswordUtilities.GeneratePassword(wrapper.Password, wrapper.Salt);
                wrapper.BirthDate = DateTime.Now;

                UserAccess ua = new UserAccess();
                ua.AddUser(wrapper);

                status = CreateUserStatus.UserCreated;

                return wrapper;
            }

            return null;
        }
Beispiel #8
0
        public void UpdateUser(UserWrapper user)
        {
            UserTableAdapter adapter=new UserTableAdapter();
            adapter.Update(user.UserID, user.FirstName, user.LastName, user.BirthDate, user.Role,
                           user.UserName, user.Password);

            DiciplineTableAdapter da = new DiciplineTableAdapter();

            foreach (var diciplineWrapper in user.Dicipline)
            {
                da.InsertInterest(user.UserID, diciplineWrapper.DiciplineId);
            }

            SubscriptionTableAdapter sa = new SubscriptionTableAdapter();

            foreach (var subWrapper in user.Subscriptions)
            {
                sa.Insert(subWrapper.UnitCode, subWrapper.UserId);
            }
        }
Beispiel #9
0
        public void AddUser(UserWrapper user)
        {
            UserTableAdapter adapter=new UserTableAdapter();
            adapter.Insert(user.FirstName, user.LastName, user.BirthDate, user.Role, user.UserName, user.Password,
                           user.Salt);

            DBDataSet.UserDataTable res = adapter.GetData(user.UserName);

            DiciplineTableAdapter da=new DiciplineTableAdapter();
            foreach (var diciplineWrapper in user.Dicipline)
            {
                da.InsertInterest(res.FirstOrDefault().UserID, diciplineWrapper.DiciplineId);
            }

            SubscriptionTableAdapter sa=new SubscriptionTableAdapter();
            foreach (var subWrapper in user.Subscriptions)
            {
                sa.Insert(subWrapper.UnitCode, subWrapper.UserId);
            }
        }
Beispiel #10
0
 private void validateUser(UserWrapper user, out CreateUserStatus status)
 {
     status = CreateUserStatus.UserValidated;
 }
Beispiel #11
0
 public bool IsSubscribedTo(UserWrapper user, UnitWrapper unit)
 {
     return user.Subscriptions.Any(sub => String.Equals(sub.UnitCode, unit.UnitCode, StringComparison.InvariantCultureIgnoreCase));
 }
Beispiel #12
0
 public void MarkNotificationAsRead(UserWrapper userWrapper, int responseId)
 {
     NotificationTableAdapter adapter=new NotificationTableAdapter();
     adapter.Notification_MarkNotificationAsRead(userWrapper.UserName, responseId);
 }
 public void MarkNotificationAsRead(UserWrapper userWrapper, int responseId)
 {
     NotificationAccess na=new NotificationAccess();
     na.MarkNotificationAsRead(userWrapper, responseId);
 }
 public int GetNumberOfUnreadNotifications(UserWrapper userWrapper)
 {
     NotificationAccess ua = new NotificationAccess();
     return ua.GetNumberOfUnreadNotifications(userWrapper);
 }
Beispiel #15
0
 private UserWrapper getUserWrapper(DBDataSet.UserRow tbl)
 {
     DiciplineAccess da=new DiciplineAccess();
     UserWrapper uw = new UserWrapper
         {
             BirthDate = tbl.BirthDate,
             FirstName = tbl.FirstName,
             LastName = tbl.LastName,
             Role = tbl.Role,
             UserID = tbl.UserID,
             UserName = tbl.Username,
             Salt = tbl.Salt,
             Password = tbl.Password,
             Dicipline = GetDiciplinesByUserId(tbl.UserID).ToList(),
             Subscriptions = GetSubscriptionsByUserId(tbl.UserID).ToList()
         };
     return uw;
 }