public override int CreateUser(string login, string password)
        {
            using (DataEntities ctx = new DataEntities())
            {
                if (ctx.users.FirstOrDefault(u => u.login == login) == null)
                {
                    user new_user = new user()
                    {
                        login = login,
                        password = password,
                        status = 0,
                        description = "",
                        last_status_update = DateTime.UtcNow,
                        last_messages_download = DateTime.UtcNow
                    };
                    ctx.users.Add(new_user);
                    ctx.SaveChanges();

                    return ctx.users.FirstOrDefault(u => u.login == login).user_id;
                }

                throw new UserAlreadyExistsException();
            }
        }
        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;
        }