コード例 #1
0
ファイル: AccountContext.cs プロジェクト: NerdCats/TaskCat
        // Register is always used for someone not in the database, only first time User or first time Asset use this method
        public async Task<AccountResult> RegisterUser(RegistrationModelBase model)
        {
            UserProfile profile;
            User user = null;

            switch (model.Type)
            {
                case IdentityTypes.USER:
                    profile = new UserProfile(model as UserRegistrationModel);
                    user = new User(model as UserRegistrationModel, profile);
                    break;
                case IdentityTypes.BIKE_MESSENGER:
                case IdentityTypes.CNG_DRIVER:
                    profile = new AssetProfile(model as AssetRegistrationModel);
                    user = new Asset(model as AssetRegistrationModel, profile as AssetProfile);
                    break;
                case IdentityTypes.ENTERPRISE:
                    var enterpriseProfile = new EnterpriseUserProfile(model as EnterpriseUserRegistrationModel);
                    user = new EnterpriseUser(model as EnterpriseUserRegistrationModel, enterpriseProfile);
                    break;

            }
            var identityResult = await accountManager.CreateAsync(user, model.Password);
            var creationResult = new AccountResult(identityResult, user);

            return creationResult;
        }
コード例 #2
0
ファイル: AccountContext.cs プロジェクト: NerdCats/TaskCat
        public async Task<SendEmailResponse> NotifyUserCreationByMail(User user)
        {
            string code = await this.accountManager.GenerateEmailConfirmationTokenAsync(user.Id);

            var clientSettings = Settings.Get<ClientSettings>();
            clientSettings.Validate();

            var confirmEmailRouteParams = new Dictionary<string, string>() { { "userId", user.Id }, { "code", code } };
            var confirmationUrl = string.Concat(clientSettings.WebCatUrl, clientSettings.ConfirmEmailPath, confirmEmailRouteParams.ToQuerystring());

            var result = await mailService.SendWelcomeMail(new SendWelcomeEmailRequest()
            {
                RecipientEmail = user.Email,
                RecipientUsername = user.UserName,
                ConfirmationUrl = confirmationUrl.ToString()
            });
            return result;
        }
コード例 #3
0
ファイル: UserDB.cs プロジェクト: MehmetAtabey/Library-System
        public MethodResponse UpdateUserForWCF(User _user)
        {
            MethodResponse methodresponse = new MethodResponse();
            try
            {
                User user = UpdateUser(_user);
                methodresponse.Type = MethodResponse.ResponseType.Succeed;
                methodresponse.ResultText = "User Updated";
                methodresponse.Object = user;
            }
            catch (Exception ex)
            {
                CustomException custom_exception = new CustomException()
                {
                    Exception = ex,
                    ExceptionTime = DateTime.Now,
                    Parameters = "",
                    HelpLink = "",
                    User = "",
                    MethodName = "UpdateUserForWCF"
                };
                CustomExceptionDB custom_exceptionDB = new CustomExceptionDB();
                bool isSaved = custom_exceptionDB.SaveException(custom_exception);
                if (isSaved == true)
                {
                    //..
                }
                methodresponse.Object = null;
                methodresponse.Type = MethodResponse.ResponseType.Error;
                methodresponse.ResultText = "An Error Occurred While Updating User";



            }
            return methodresponse;
        }
コード例 #4
0
ファイル: UserDB.cs プロジェクト: MehmetAtabey/Library-System
        public User UpdateUser(User _user)
        {
            try
            {
                using (var context = new LibrarySystemEntities())
                {
                    User olduser = context.Users.FirstOrDefault(c => c.UserId == _user.UserId);
                    if (olduser != null)
                    {
                        olduser.FirstName = _user.FirstName;
                        olduser.LastName = _user.LastName;
                        olduser.Password = _user.Password;
                        

                        context.SaveChanges();
                        return olduser;
                    }
                    return null;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
コード例 #5
0
ファイル: UserDB.cs プロジェクト: MehmetAtabey/Library-System
        public User AddUser(User _user)
        {
            try
            {
                using (var context = new LibrarySystemEntities())
                {
                    context.Users.Add(_user);

                    context.SaveChanges();
                    return _user;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }