public void removeAccount(AccountEntity account) { accounts.Remove(account); if (null != PropertyChanged) { PropertyChanged(null, null); } }
public async Task<UserResponse> UpdateAccountAsync(string description = "", string timezone = "America/New_York") { var account = new AccountEntity() { timeZone = timezone, description = description }; var result = await _webManager.PostData(new Uri(Endpoints.Account), null, new StringContent(JsonConvert.SerializeObject(account), Encoding.UTF8, "application/json")); return JsonConvert.DeserializeObject<UserResponse>(result.ResultJson); }
/// <summary> /// 请求加入房间 /// </summary> /// <param name="roomId"></param> public void RequestJoinRoom(int roomId) { if (m_isBusy) { return; } m_isBusy = true; UIViewManager.Instance.ShowWait(); Dictionary <string, object> dic = new Dictionary <string, object>(); AccountEntity entity = AccountProxy.Instance.CurrentAccountEntity; dic["passportId"] = entity.passportId; dic["token"] = entity.token; dic["bundleId"] = DeviceUtil.GetBundleIdentifier(); dic["roomId"] = roomId; NetWorkHttp.Instance.SendData(ConstDefine.WebUrl + ConstDefine.HTTPAddrJoin, OnRequestJoinRoomCallBack, true, ConstDefine.HTTPFuncJoin, dic); }
public ActionResult GetFormJson(string keyValue) { var entity = new AccountEntity(); try { entity = accountApp.FindList(c => c.accountGuid == keyValue)[0]; WirteOperationRecord("Account", "SELECT", "查询", "Info:获取讲师资料(单个)"); } catch (Exception ex) { log.logType = "ERROR"; log.logLevel = "ERROR"; WirteOperationRecord("Account", "", "", "Info:" + ex.Message.ToString()); } return(Content(entity.ToJson())); }
public async Task <AccountEntity> CreateAccountAsync(AccountEntity account) { using SqlConnection db = new SqlConnection(_dalSettings.ConnectionString); return(await db.QuerySingleOrDefaultAsync <AccountEntity>( "CreateAccount", new { firstName = account.FirstName, secondName = account.SecondName, email = account.Email, passwordHash = account.PasswordHash, salt = account.Salt, role = AccountRole.User }, commandType : CommandType.StoredProcedure)); }
private void CheckEquals(AccountEntity entity1, AccountEntity entity2) { Assert.AreEqual(entity1.Id, entity2.Id); Assert.AreEqual(entity1.AccountName, entity2.AccountName); Assert.AreEqual(entity1.AccountType, entity2.AccountType); Assert.AreEqual(entity1.AccountStatus, entity2.AccountStatus); Assert.AreEqual(entity1.Token, entity2.Token); Assert.AreEqual(entity1.Identity, entity2.Identity); Assert.AreEqual(entity1.Name, entity2.Name); Assert.AreEqual(entity1.Email, entity2.Email); Assert.AreEqual(entity1.Phone, entity2.Phone); Assert.AreEqual(entity1.Gender, entity2.Gender); Assert.AreEqual(entity1.ProfileImage, entity2.ProfileImage); Assert.AreEqual(entity1.ProfileThumbnail, entity2.ProfileThumbnail); Assert.AreEqual(entity1.LastLoginDateTime, entity2.LastLoginDateTime); Assert.AreEqual(entity1.CreatedTime.ToString("s"), entity2.CreatedTime.ToString("s")); }
async void OnNextClick(object sender, EventArgs e) { App.IsUserLoggedIn = true; AccountEntity account = previouspage.previouspage.accountEntity; account.Id = Guid.NewGuid().ToString(); AreaConfigurationEntity area = previouspage.areaConfigurationEntity; area.AccountId = account.Id; ApplicationHandler.LoggedInAccount = account; ApplicationHandler.AreaConfiguration = area; await MobileService.MobileServiceClient.GetTable <AccountEntity>().InsertAsync(account); await MobileService.MobileServiceClient.GetTable <AreaConfigurationEntity>().InsertAsync(area); Application.Current.MainPage = new MainPage(); }
/// <summary> /// /// </summary> /// <returns></returns> public virtual ActionResult Modify(PasswordModel model) { if (model.NewPassword != model.SurePassword) { model.Errors = model.Errors ?? new List <ErrorInfo> { new ErrorInfo { Key = "SurePasswordError", Message = "两次输入密码不一致" } }; return(View("~/Views/Account/Password/Index.cshtml", model)); } if (string.IsNullOrEmpty(model.OldPassword)) { model.Errors = model.Errors ?? new List <ErrorInfo> { new ErrorInfo { Key = "OldPasswordEmpty", Message = "请输入原始密码" } }; return(View("~/Views/Account/Password/Index.cshtml", model)); } var rev = Ioc.Resolve <IPasswordApplicationService>().CheckPassword(Identity.Id, model.OldPassword); if (!rev) { model.Errors = model.Errors ?? new List <ErrorInfo> { new ErrorInfo { Key = "OldPasswordError", Message = "原始密码错误" } }; return(View("~/Views/Account/Password/Index.cshtml", model)); } var account = new AccountEntity { Id = Identity.Id, Password = model.NewPassword, SaveType = SaveType.Modify }; account.SetProperty(it => it.Password); this.SaveEntity(account); model.Errors = account.Errors; return(View("~/Views/Account/Password/Index.cshtml", model)); }
public async Task <ViewResult> Edit(int id) { AccountEntity account = await unitOfWork.AccountRepository.GetByID(id); var model = new AccountModel { AccountId = account.AccountId, Name = account.Name, Surname = account.Surname, MiddleName = account.MiddleName, Email = account.Email, Login = account.Login, AccessLevel = account.AccessLevel }; return(View("Edit", model)); }
private static async Task <AccountEntity> InsertAccountEntityAsync(RivaIdentityDbContext context) { var accountEntity = new AccountEntity { Id = AuthUserOptions.UserId, Email = AuthUserOptions.Email, Confirmed = true, PasswordHash = "PasswordHash", SecurityStamp = Guid.NewGuid(), Created = DateTimeOffset.UtcNow }; context.Accounts.Add(accountEntity); await context.SaveChangesAsync(); return(accountEntity); }
public async void Delete_EntryNotFound() { // Arrange var factory = new DbFactory(); var unitOfWork = new UnitOfWork(factory); var repository = new AccountRepository(factory); var testEntry = new AccountEntity { Name = "testAccount" }; // Act repository.Delete(testEntry); // Assert await Assert.ThrowsAsync <DbUpdateConcurrencyException>(async() => await unitOfWork.Commit()); }
/// <summary> /// 微信支付订单 /// </summary> /// <param name="propId"></param> /// <param name="channelId"></param> private void WXPayOrder(int propId, int channelId) { if (m_isBusy) { return; } #if UNITY_IPHONE if (m_isHasOrder && GlobalInit.Instance.PaymentType == PaymentType.Official) { ShowMessage("提示", "当前有没处理完的订单"); return; } m_isHasOrder = true; #endif m_isBusy = true; UIViewManager.Instance.ShowWait(); Dictionary <string, object> dic = new Dictionary <string, object>(); AccountEntity entity = AccountProxy.Instance.CurrentAccountEntity; dic["passportId"] = entity.passportId; dic["token"] = entity.token; dic["configId"] = propId; if (SystemProxy.Instance.IsInstallWeChat && SystemProxy.Instance.IsOpenWXLogin) { dic["channelId"] = 1; } else { dic["channelId"] = m_Channel; } #if UNITY_IPHONE if (GlobalInit.Instance.PaymentType == PaymentType.Official) { dic["channelId"] = 2; } #endif if (channelId != 0) { dic["channelId"] = channelId; } NetWorkHttp.Instance.SendData(ConstDefine.WebUrl + ConstDefine.HTTPAddrWXPayOrder, OnWXPayOrderCallBack, true, ConstDefine.HTTPFuncWXPayOrder, dic); }
public void AddSpectator(Client sender, int id) { if (!sender.HasRank(ServerRank.Support3)) { sender.SendWarning("Nie posiadasz uprawnień do ustawienia obserwowania."); return; } AccountEntity controller = EntityHelper.GetAccountByServerId(id); if (controller == null) { sender.SendError("Nie znaleziono gracza o podanym Id."); return; } NAPI.Player.SetPlayerToSpectator(controller.Client); sender.SendInfo("Włączono obserwowanie."); }
public static Account ToDomain(this AccountEntity account) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <AccountEntity, Account>() .ForMember(e => e.Email, opt => opt.MapFrom(src => src.Email)); cfg.CreateMap <CustomerEntity, Customer>() .ForMember(e => e.Name, opt => opt.MapFrom(src => src.Name)); cfg.CreateMap <AccountEntity, Account>() .ForMember(e => e.Customer, opt => opt.MapFrom(src => src.Customer)); }); var mapper = new Mapper(config); return(mapper.Map <AccountEntity, Account>(account)); }
public static void Main(string[] args) { // CreateWebHostBuilder(args).Build().Run(); var host = BuildWebHost(args); using (var serviceScope = host.Services.CreateScope()) { var context = serviceScope.ServiceProvider.GetRequiredService <MovieDbContext>(); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.Account.AddRange(AccountEntity.CreateDumpData()); context.Movie.AddRange(MovieEntity.CreateDumpData()); context.MovieLikes.AddRange(MovieLikesEntity.CreateDumpData()); context.SaveChanges(); } host.Run(); }
private static async Task <AccountEntity> InsertAccountEntityAsync(RivaIdentityDbContext context) { var accountEntity = new AccountEntity { Id = Guid.NewGuid(), Email = "*****@*****.**", Confirmed = true, PasswordHash = "PasswordHash", SecurityStamp = Guid.NewGuid(), Created = DateTimeOffset.UtcNow }; context.Accounts.Add(accountEntity); await context.SaveChangesAsync(); return(accountEntity); }
public async Task GetWalletTradeBalanceByAssetId() { string url = ApiPaths.WALLETS_TRADING_BALANCES_PATH + "/" + this.TestAssetId; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.GET); Assert.True(response.Status == HttpStatusCode.OK); WBalanceDTO parsedResponse = JsonUtils.DeserializeJson <WBalanceDTO>(response.ResponseJson); AccountEntity entity = await this.AccountRepository.TryGetAsync(this.TestClientId) as AccountEntity; Assert.NotNull(entity); BalanceDTO entityBalance = entity.BalancesParsed.Where(b => b.Asset == this.TestAssetId).FirstOrDefault(); Assert.NotNull(entityBalance); Assert.True(entityBalance.Balance == parsedResponse.Balance); }
public async Task <AccountEntity> SaveAsync(AccountEntity accountEntity) { if (string.IsNullOrEmpty(accountEntity.Id) == true) { var id = Guid.NewGuid().ToString(); accountEntity.Id = id; _accounts.TryAdd(id, accountEntity); _accountsByUserId.TryAdd(accountEntity.UserId, accountEntity); } else { Func <string, AccountEntity, AccountEntity> func = (k, oldValue) => accountEntity; _accounts.AddOrUpdate(accountEntity.Id, accountEntity, func); _accountsByUserId.AddOrUpdate(accountEntity.UserId, accountEntity, func); } return(accountEntity); }
public IHttpActionResult UpdateAccount(AccountEntity account) { bool isUpdateSuccess = false; ResultEntity result = new ResultEntity(); try { isUpdateSuccess = this.dal.UpdateAccount(account.ToACCOUNT()); } catch (Exception e) { result.Message = e.Message; NtripProxyLogger.LogExceptionIntoFile("调用接口api/Account/UpdateAccount异常,异常信息为:" + e.Message); } result.IsSuccess = isUpdateSuccess; return(Json <ResultEntity>(result)); }
public void OnPlayerPlaceOrderHandler(Client sender, params object[] arguments) { /* Argumenty * args[0] - List<WarehouseItemInfo> JSON */ AccountEntity player = sender.GetAccountEntity(); GroupEntity group = player.CharacterEntity.OnDutyGroup; if (group != null) { List <WarehouseItemInfo> items = JsonConvert.DeserializeObject <List <WarehouseItemInfo> >(arguments[0].ToString()); decimal sum = items.Sum(x => x.ItemModelInfo.Cost * x.Count); if (group.HasMoney(sum)) { GroupWarehouseOrderModel shipment = new GroupWarehouseOrderModel { //Getter = group.DbModel, //OrderItemsJson = JsonConvert.SerializeObject(items), //ShipmentLog = $"[{DateTime.Now}] Złożenie zamówienia w magazynie. \n" }; RoleplayContext ctx = Singletons.RoleplayContextFactory.Create(); using (GroupWarehouseOrdersRepository repository = new GroupWarehouseOrdersRepository(ctx)) { repository.Insert(shipment); repository.Save(); } group.RemoveMoney(sum); CurrentOrders.Add(new WarehouseOrderInfo { Data = shipment }); sender.SendInfo("Zamawianie przesyłki zakończyło się pomyślnie."); } else { sender.SendError($"Grupa {group.GetColoredName()} nie posiada wystarczającej ilości środków."); } } }
public static AccountDTO ToAccauntDTO(this AccountEntity accountEntity) { OwnerDTO ownerDTO = accountEntity.Owner.ToOwnerDTO(); AccountDTO accountDTO = new AccountDTO() { Id = accountEntity.Id, Number = accountEntity.Number, AccountTypeId = accountEntity.AccountType.Id, Balance = accountEntity.Balance, BonusPoints = accountEntity.BonusPoints, IsOponed = accountEntity.IsOponed, Owner = ownerDTO }; return(accountDTO); }
/// <summary> /// 判断账户是否存在 /// </summary> /// <param name="entity"></param> /// <returns></returns> private async Task <IResultModel> Exists(AccountEntity entity) { if (await _accountRepository.ExistsUserName(entity.UserName, entity.Id)) { return(ResultModel.Failed("用户名已存在")); } if (entity.Phone.NotNull() && await _accountRepository.ExistsPhone(entity.Phone, entity.Id)) { return(ResultModel.Failed("手机号已存在")); } if (entity.Email.NotNull() && await _accountRepository.ExistsEmail(entity.Email, entity.Id)) { return(ResultModel.Failed("邮箱已存在")); } return(ResultModel.Success()); }
public async Task ThenAccountIsUpdatedIfExisting( AccountsRepository sut, AccountEntity newEntity) { // Arrange await sut.AddOrUpdate(newEntity); var expectedCountAfterUpdate = (await sut.GetList()).Count; // Act await sut.AddOrUpdate(newEntity); // Assert var actualCountAfterAdd = (await sut.GetList()).Count; actualCountAfterAdd.Should().Be(expectedCountAfterUpdate); }
public ActionResult SubmitForm(AccountEntity entity, string keyValue) { try { accountApp.SubmitForm(entity, keyValue); if (string.IsNullOrEmpty(keyValue)) { //插入用户角色 string roleName = "学生"; if (entity.accountType == 1) { roleName = "管理员"; } else if (entity.accountType == 2) { roleName = "讲师"; } var roleEntity = roleApp.FindEntity(c => c.roleName.Contains(roleName)); var accountRole = new AccountRoleEntity() { roleInfoGuid = roleEntity.roleGuid, accountInfoGuid = entity.accountGuid }; accountRoleApp.SubmitForm(accountRole, ""); } if (string.IsNullOrEmpty(keyValue)) { WirteOperationRecord("Account", "INSERT", "增加", "Info:" + entity.ToJson()); } else { WirteOperationRecord("Account", "UPDATE", "修改", "Info:" + entity.ToJson()); } } catch (Exception ex) { log.logType = "ERROR"; log.logLevel = "ERROR"; WirteOperationRecord("Account", "", "", "Info:" + ex.Message.ToString()); return(Error(ex.Message.ToString())); } return(Success("操作成功.")); }
public async Task <CompanyModel> FireMember(AuthorizedDto <FireHireDto> model) { return(await Execute(async() => { using (UnitOfWork db = new UnitOfWork()) { AccountEntity account = await db.GetRepo <AccountEntity>().Get(model.Data.AccountId.Value); if (account == null) { throw new NotFoundException("Account"); } if (!account.company_id.HasValue || account.company_id != model.Data.CompanyId) { throw new NotHiredException(); } if (account.company_id.Value == account.id) //OWNER { throw new NotPermittedException(); } account.company_id = null; account.Roles.Clear(); account.Bosses.Clear(); account.Subs.Clear(); foreach (TaskEntity task in account.AssignedTasks) { task.assignee_account_id = null; } foreach (TaskEntity task in account.TasksToReview) { task.reviewer_account_id = null; } IList <RoleEntity> defaultRoles = await db.GetRepo <RoleEntity>().Get(role => role.is_default); account.Roles.Add(defaultRoles.FirstOrDefault(role => role.name == DefaultRoles.AUTHORIZED.ToName())); await db.Save(); return await GetCompany(model.Data.CompanyId.Value); } })); }
/// <summary> /// 检测账户 /// </summary> /// <returns></returns> private bool CheckAccount(AccountEntity account, out string msg) { msg = ""; if (account.Status == AccountStatus.Closed) { msg = "该账户已注销,请联系管理员~"; return(false); } if (account.Status == AccountStatus.Disabled) { msg = "该账户已禁用,请联系管理员~"; return(false); } return(true); }
public async Task <DaoResultMessage> UpdataAccount(string id, AccountEntity entity) { DaoResultMessage message = new DaoResultMessage(); try { using (var context = new DjLiveCpContext()) { var dbentity = context.Account.FirstOrDefault(obj => obj.Id == id); if (dbentity != null && entity != null) { dbentity.Password = string.IsNullOrEmpty(entity.Password) ? dbentity.Password : entity.Password; dbentity.Token = string.IsNullOrEmpty(entity.Token) ? dbentity.Token : entity.Token; dbentity.RoleType = entity.RoleType == 0 ? dbentity.RoleType : entity.RoleType; dbentity.StatType = entity.StatType == 0 ? dbentity.StatType : entity.StatType; context.Account.Attach(dbentity); context.Entry(dbentity).Property(x => x.Id).IsModified = false; context.Entry(dbentity).Property(x => x.UserName).IsModified = false; context.Entry(dbentity).Property(x => x.Token).IsModified = true; context.Entry(dbentity).Property(x => x.Password).IsModified = true; context.Entry(dbentity).Property(x => x.RoleType).IsModified = true; context.Entry(dbentity).Property(x => x.StatType).IsModified = true; await context.SaveChangesAsync(); message.Code = DaoResultCode.Success; message.Message = "修改成功!"; message.para = entity; } else { message.Code = DaoResultCode.ItemNotExist; message.Message = "修改失败,对象不存在!"; } } } catch (Exception e) { LogHelper.Error(e.Message, e); message.Code = DaoResultCode.UnExpectError; message.Message = e.Message; } return(message); }
public ActionResult Signup(SignupModel model, string returnUrl) { AccountEntity newAccount = new AccountEntity(); newAccount.Name = model.Name; newAccount.MiddleName = model.MiddleName; newAccount.Surname = model.Surname; newAccount.Email = model.Email; newAccount.Login = model.Login; //newAccount.Password = Feature.SetPass(10); newAccount.AccessLevel = 3; //Feature.SendEmail(newAccount.Email, "Your credentials!", // String.Format("Hello, {0} {1}! You recieved this email because You have registered on the Effort Time Tracking System earlier. \nPlease, use this credentials to sign in:\nLogin: {2}\nPassword: {3}\nPlease do not forget your password.", // newAccount.Name, newAccount.Surname, newAccount.Login, newAccount.Password)); unitOfWork.AccountRepository.Insert(newAccount); return(Redirect(returnUrl ?? Url.Action("Login", "Account"))); }
public virtual ActionResult Register() { try { var info = new AccountEntity(); var mess = Register(info); return(mess ? ReturnSuccessResult("注册成功") : ReturnFailureResult(info.Errors != null && info.Errors.Count > 0 ? string.Join(",", info.Errors.Select(it => it.Message).ToArray()) : "注册失败")); } catch (Exception ex) { return(ReturnExceptionResult(ex)); } }
private async Task PrepareTestData() { var TestClient = await Consumer.RegisterNewUser(); TestClientId = TestClient.Account.Id; var walletsFromDB = this.WalletRepository.GetAllAsync(w => w.ClientId == TestClientId && w.State != "deleted"); var operationsFromDB = this.OperationsRepository.GetAllAsync(o => o.PartitionKey == OperationsEntity.GeneratePartitionKey() && o.ClientId.ToString() == TestClientId); this.TestAssetId = Constants.TestAssetId; this.AssetPrecission = 2; this.AllWalletsFromDb = (await walletsFromDB).Cast <WalletEntity>().ToList(); this.TestWallet = await CreateTestWallet(); //fill wallet with funds await MEConsumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestWallet.Id, Constants.TestAssetId, 50.0); this.TestWalletWithBalanceId = TestWallet.Id; this.TestWalletDelete = await CreateTestWallet(); this.TestWalletAccount = await AccountRepository.TryGetAsync(TestWallet.Id) as AccountEntity; this.TestWalletOperations = await CreateTestWallet(); this.TestWalletRegenerateKey = await CreateTestWallet(true); this.TestOperation = await CreateTestOperation(); this.TestOperationCancel = await CreateTestOperation(); this.TestOperationCreateDetails = await CreateTestOperation(); this.TestOperationRegisterDetails = await CreateTestOperation(); this.ClientInfoConsumer = new ApiConsumer(_apiV2Settings); await this.ClientInfoConsumer.RegisterNewUser(); AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(ClientInfoConsumer.ClientInfo.Account.Id)); // set the id to the default one in case it has been changed by any test BaseAssetDTO body = new BaseAssetDTO(this.TestAssetId); var response = await Consumer.ExecuteRequest(ApiPaths.ASSETS_BASEASSET_PATH, Helpers.EmptyDictionary, JsonUtils.SerializeObject(body), Method.POST); }
public JsonResult GetMemberList(int groupId) { string functionName = System.Reflection.MethodBase.GetCurrentMethod().Name; try { //Check value enter id group if (groupId == 0) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.emailAndPasswordWrong)); return(Json(MessageResult.GetMessage(MessageType.EMAIL_AND_PASSWORD_WRONG))); } List <GroupMemberEntity> memberEntities = _groupRepository.GetMemberListByGroupId(groupId); if (memberEntities == null) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.notInformationAccount)); return(Json(MessageResult.GetMessage(MessageType.NOT_INFORMATION_MEMBER))); } List <MemberListResult> memberListResult = new List <MemberListResult>(); foreach (var members in memberEntities) { MemberListResult memberList = new MemberListResult(); memberList.groupMemberId = members.GroupMemberId; memberList.groupId = members.GroupId; memberList.accountId = members.AccountId; AccountEntity accountEntity = _accountRepository.GetAccountById(members.AccountId); memberList.email = accountEntity.Email; memberList.fullName = accountEntity.FullName; memberList.address = accountEntity.Address; memberList.phoneNumber = accountEntity.Phone; memberListResult.Add(memberList); } return(Json(memberListResult)); } catch (Exception ex) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(ex.Message)); return(Json(MessageResult.ShowServerError(ex.Message))); } }
public async void Delete_EntryMatchedFilterDeleted() { // Arrange var filterText = "Text"; var paymentRepository = new PaymentRepository(ambientDbContextLocator); var accountRepository = new AccountRepository(ambientDbContextLocator); var testAccount = new AccountEntity { Name = "testAccount" }; using (var dbContextScope = dbContextScopeFactory.Create()) { accountRepository.Add(testAccount); await dbContextScope.SaveChangesAsync(); } var testEntry1 = new PaymentEntity { ChargedAccount = testAccount, Note = filterText }; var testEntry2 = new PaymentEntity { ChargedAccount = testAccount }; // Act using (var dbContextScope = dbContextScopeFactory.Create()) { paymentRepository.Add(testEntry1); paymentRepository.Add(testEntry2); await dbContextScope.SaveChangesAsync(); } using (var dbContextScope = dbContextScopeFactory.Create()) { paymentRepository.Delete(x => x.Note == filterText); await dbContextScope.SaveChangesAsync(); } // Assert using (dbContextScopeFactory.CreateReadOnly()) { Assert.Equal(1, paymentRepository.GetAll().Count()); } }
public AccountValue SignUp(SignUpValue signUpValue) { var userEntity = new UserEntity() { LastName = signUpValue.LastName, FirstName = signUpValue.FirstName }; var accountEntity = new AccountEntity() { Email = signUpValue.Email, Password = signUpValue.Password, User = userEntity }; _repository.Add(accountEntity); if (_repository.CommitChanges() > 0) { return Mapper.Map<AccountValue>(accountEntity); } throw new Exception("Error was occured while creating an account"); }
/// <summary> /// Creates an account with given id and password. /// </summary> /// <param name="accountId">The account id.</param> /// <param name="password">The account password.</param> public void CreateAccount( EmailAddress accountId, SecureString password) { PasswordHash passwordHash = PasswordHash.Create(password); CloudTable loginTable = this.GetLoginTable(); CloudTable accountTable = this.GetAccountTable(); LoginEntity existingEntity = FindExistingLogin(loginTable, accountId); if (existingEntity != null) { if (existingEntity.Activated) { throw new InvalidOperationException("account already activated."); } AccountEntity existingAccount = FindExistingAccount(accountTable, accountId); if (existingAccount == null) { existingAccount = new AccountEntity(); existingAccount.PartitionKey = accountId.Domain; existingAccount.RowKey = accountId.LocalPart; } else if (existingAccount.CreatedTime + ActivationTimeout > DateTime.UtcNow) { throw new InvalidOperationException("Account creation cannot be retried yet."); } existingEntity.Salt = passwordHash.Salt; existingEntity.SaltedHash = passwordHash.Hash; TableOperation replaceOperation = TableOperation.InsertOrReplace(existingEntity); loginTable.Execute(replaceOperation); existingAccount.CreatedTime = DateTime.UtcNow; TableOperation insertAccountOperation = TableOperation.InsertOrReplace(existingAccount); accountTable.Execute(insertAccountOperation); } else { LoginEntity newEntity = new LoginEntity(); newEntity.PartitionKey = accountId.Domain; newEntity.RowKey = accountId.LocalPart; newEntity.Salt = passwordHash.Salt; newEntity.SaltedHash = passwordHash.Hash; TableOperation insertOperation = TableOperation.Insert(newEntity); loginTable.Execute(insertOperation); AccountEntity newAccount = new AccountEntity(); newAccount.PartitionKey = accountId.Domain; newAccount.RowKey = accountId.LocalPart; newAccount.CreatedTime = DateTime.UtcNow; TableOperation insertAccountOperation = TableOperation.InsertOrReplace(newAccount); accountTable.Execute(insertAccountOperation); } }
private StaffEntity CreateNewStaff(int staffIndex, OrgEntity org, AccountEntity account) { StaffEntity staff = new StaffEntity(); staff.Id = Guid.NewGuid(); staff.Account = account; staff.Org = org; staff.Name = account.Name; return staff; }
private AccountEntity CreateNewAccount(int accountIndex) { AccountEntity account = new AccountEntity(); account.Id = Guid.NewGuid(); account.Name = "Account-" + accountIndex; account.Email = account.Name + "example.com"; account.Password = "******"; account.PasswordFormat = PasswordFormats.ClearText; account.CreatedAt = DateTime.Now; return account; }
public void AddToAccountEntitySet(AccountEntity accountEntity) { base.AddObject("AccountEntitySet", accountEntity); }
public static AccountEntity CreateAccountEntity(int accountId, decimal startAmount) { AccountEntity accountEntity = new AccountEntity(); accountEntity.AccountId = accountId; accountEntity.StartAmount = startAmount; return accountEntity; }