コード例 #1
0
ファイル: SignUpService.cs プロジェクト: lilin19/Arbiter.net
        public int Signup(SignUpModel sup)
        {
            if (userio.LoadEntity(u => u.Username == sup.UserName).FirstOrDefault() != null)
            {
                return(ErrorType.DeplicatedUser.GetHashCode());
            }
            var user = new User();

            user.Id       = Guid.NewGuid().ToString();
            user.Name     = sup.Name;
            user.Password = sup.Password;
            user.Username = sup.UserName;

            try
            {
                userio.CreateEntity(user);
                userio.container.SaveChanges();
                return(ErrorType.Success.GetHashCode());
            }
            catch (Exception e)
            {
                return(ErrorType.IOError.GetHashCode());
            }
        }