public int CreateUser(PersonalInformation info)
        {
            string            jsonInfo  = JsonConvert.SerializeObject(info);
            CodedPersonalInfo codedUser = new CodedPersonalInfo(jsonInfo);
            int userId = UserList.Instance.AddUser(codedUser);

            return(userId);
        }
        public PersonalInformation GetInfoById(int id)
        {
            CodedPersonalInfo codedUser = UserList.Instance.GetUser(id);

            if (codedUser != null)
            {
                PersonalInformation user = JsonConvert.DeserializeObject <PersonalInformation>(codedUser.Info);
                return(user);
            }

            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Add user to the list if it does not exist there and returns it's unique id. Otherwise returns -1.
        /// </summary>
        public int AddUser(CodedPersonalInfo userInfo)
        {
            bool userExists = userList.Contains(userInfo);

            if (!userExists)
            {
                userList.Add(userInfo);
                return(userList.Count - 1);
            }

            return(-1);
        }