public UserDataResponse(User usr)
 {
     user_id = usr.user_id;
     login = usr.login;
     status = (int)usr.status;
     description = usr.descripton;
 }
        private User Convert(user u)
        {
            if (u == null)
                return null;

            User entity = new User(u.user_id, u.login, u.password)
            {
                descripton = u.description,
                last_status_update = u.last_status_update,
                last_messages_download = u.last_messages_download,
                status = (EUserStatus)u.status,
                contact_list = new Dictionary<string,int>()
            };

            foreach (contact contact in u.contacts)
            {
                entity.contact_list[contact.name] = contact.contact_id;
            }

            return entity;
        }
        public override int CreateUser(string login, string password)
        {
            lock (users)
            {
                if (GetUser(login) == null)
                {
                    User u = new User(++last_user_id, login, password);
                    users.Add(u);
                    return u.user_id;
                }

                throw new UserAlreadyExistsException();
            }
        }
Esempio n. 4
0
 public static Dictionary<string, User> GetContactList(User user)
 {
     Dictionary<string, User> contact_list = new Dictionary<string, User>();
     foreach (KeyValuePair<string, int> pair in user.contact_list)
     {
         contact_list[pair.Key] = GetUser(pair.Value);
     }
     return contact_list;
 }