public ActionResult Create() { try { #region " [ Declaration ] " AccountTypeService _typeServices = new AccountTypeService(); AccountService _service = new AccountService(); // ViewBag.type = _typeServices.GetAll(UserID); #endregion //Call to service AccountModel model = new AccountModel() { ID = Guid.NewGuid(), CreateBy = UserID, Insert = true }; // return(View(model)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, UserID, ex); } }
public JsonResult CheckDelete(AccountTypeModel model) { try { #region " [ Declaration ] " AccountTypeService _service = new AccountTypeService(); #endregion #region " [ Main process ] " model.CreateBy = UserID; #endregion //Call to service return(this.Json(_service.CheckDelete(model), JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, UserID, ex); } }
public void CreateAccountTypes_saves_AccountTypes_via_context() { var options = new DbContextOptionsBuilder <IpsDBContext>() .UseInMemoryDatabase(databaseName: "Add_writes_to_database") .Options; // Run the test against one instance of the context using (var context = new IpsDBContext(options)) { var service = new AccountTypeService(context); AccountType accountType1 = new AccountType(); accountType1.AccountTypeName = "Personal"; AccountType accountType2 = new AccountType(); accountType2.AccountTypeName = "Corporate"; service.AddAccountType(accountType1); service.AddAccountType(accountType2); context.SaveChanges(); } // Use a separate instance of the context to verify correct data was saved to database using (var context = new IpsDBContext(options)) { Assert.Equal(2, context.AccountType.Count()); } }
public async Task MarkProfileAsDeletedTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var repository = new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options.Options)); foreach (var item in this.GetApplicationUserData()) { await repository.AddAsync(item); await repository.SaveChangesAsync(); } var store = new Mock <IUserStore <ApplicationUser> >(); var userManager = new Mock <UserManager <ApplicationUser> >(store.Object, null, null, null, null, null, null, null, null); var service = new AccountTypeService(userManager.Object, repository); await service.MarkProfileAsDeleted("1"); var user = repository.AllWithDeleted().Where(x => x.Id == "1").FirstOrDefault(); Assert.True(user.IsDeleted); }
public ActionResult Edit(string id) { try { #region " [ Declaration ] " AccountTypeService _service = new AccountTypeService(); // ViewBag.id = id; #endregion //Call to service AccountTypeModel model = _service.GetItemByID(new AccountTypeModel() { ID = new Guid(id), CreateBy = UserID, Insert = false }); // return(View(model)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, UserID, ex); } }
// GET: Customer/Create public ActionResult Create() { var model = new CustomerModel(); var accountTypeService = new AccountTypeService(); model.AccountTypeSelectList = accountTypeService.GetSelectList(); model.AccountDetails = new Account(); return(View(model)); }
public void Read(int id) { var obj = AccountTypeService.GetById(id); if (obj.State == AccountTypeStates.Normal) { InnerObject = obj; } }
protected override AccountViewModel AssignEntityToViewModel(Account entity) { var viewModel = entity.Convert <Account, AccountViewModel>(); var accountType = new AccountTypeService(UnitOfWork); viewModel = entity.Convert <Account, AccountViewModel>(); viewModel.AccountTypeName = accountType.Find(entity.AccountTypeId).Name; return(viewModel); }
private void SetServices(IUnitOfWork unitOfWork) { AccountSettingService = new AccountSettingService(unitOfWork); AccountService = new AccountService(unitOfWork, AccountSettingService); AccountTransactionService = new AccountTransactionService(unitOfWork); AccountTypeService = new AccountTypeService(unitOfWork); AccountTypeSettingTypeService = new AccountTypeSettingTypeService(unitOfWork); SettingTypeService = new SettingTypeService(unitOfWork); }
public IEnumerable <ValidationError> Validate() { if (AccountTypeService.Query(new AccountTypeRequest() { DisplayName = DisplayName }).Count() > 0) { yield return(new ValidationError("DisplayName", string.Format(Localize("messages.duplicationDisplayName"), DisplayName))); } }
public IEnumerable <ValidationError> Validate() { var type = AccountTypeService.Query(new AccountTypeRequest { DisplayName = DisplayName }).FirstOrDefault(); if (type != null && type.AccountTypeId != this.AccountTypeId) { yield return(new ValidationError("DisplayName", string.Format(Localize("messages.duplicationDisplayName"), DisplayName))); } }
public AccountController(AccountService accountService, ProviderService providerService, AccountTypeService accountTypeService, TransactionTypeService transactionTypeService, ILogger <AccountController> logger) { _accountService = accountService; _providerService = providerService; _accountTypeService = accountTypeService; _logger = logger; }
public async void SetValueInPickerAsync() { List <AccountTypeVm> accountTypeVm = new List <AccountTypeVm>(); accountTypeVm = await AccountTypeService.GetAccountTypeList(); foreach (var item in accountTypeVm) { accountTypePicker.Items.Add(item.Name); } }
protected override Income AssignViewModelToEntity(IncomeViewModel viewModel) { var entity = viewModel.Convert <IncomeViewModel, Income>(); var accountService = new AccountService(UnitOfWork); var accountTypeService = new AccountTypeService(UnitOfWork); var account = accountService.Find(entity.PaymentAccountId); var accountType = accountTypeService.Find(account.AccountTypeId); entity.Status = (accountType.Name != AccountTypeConstant.AccountsReceivable); return(entity); }
protected override AccountViewModel SetViewModelData(AccountViewModel viewModel) { var accountType = new AccountTypeService(UnitOfWork); viewModel.AccountTypes = accountType.GetAll().Select(o => new SelectListItem { Text = o.Name, Value = o.Id.ToString() }).ToList(); return(viewModel); }
public IMessageProvider Create() { var serialNo = SerialNoHelper.Create(); InnerObject.State = AccountTypeStates.Normal; AccountTypeService.Create(InnerObject); AddMessage("success", DisplayName); Logger.LogWithSerialNo(LogTypes.AccountTypeCreate, serialNo, InnerObject.AccountTypeId, DisplayName); CacheService.Refresh(CacheKeys.PointPolicyKey); return(this); }
public void Query() { AccountTypeRequest request = new AccountTypeRequest(); if (State != AccountTypeStates.All) { request.State = State; } var query = AccountTypeService.Query(request); this.List = query.ToList(this, x => new ListAccountType(x)); }
public SimpleAjaxResult Save() { try { var serialNo = SerialNoHelper.Create(); TransactionHelper.BeginTransaction(); var account = AccountService.GetById(Id); if (account != null && account.State == AccountStates.Invalid) { account.State = AccountStates.Normal; AccountService.Update(account); Logger.LogWithSerialNo(LogTypes.AccountResume, serialNo, Id, account.Name); DataAjaxResult r = new DataAjaxResult(); if (!string.IsNullOrWhiteSpace(HostSite.MessageTemplateOfAccountResume)) { var owner = account.OwnerId.HasValue ? MembershipService.GetUserById(account.OwnerId.Value) : null; if (owner != null && owner.IsMobileAvailable) { var accountType = AccountTypeService.GetById(account.AccountTypeId); if (accountType != null && accountType.IsSmsResume) { var msg = MessageFormator.Format(HostSite.MessageTemplateOfAccountResume, owner); msg = MessageFormator.Format(msg, account); SmsHelper.Send(owner.Mobile, msg); } } } if (!string.IsNullOrWhiteSpace(HostSite.TicketTemplateOfResumeAccount)) { r.Data1 = MessageFormator.FormatTickForResumeAccount( HostSite.TicketTemplateOfResumeAccount, serialNo, HostSite, account, account.OwnerId.HasValue ? MembershipService.GetUserById(account.OwnerId.Value) : null, AccountTypeService.GetById(account.AccountTypeId), SecurityHelper.GetCurrentUser().CurrentUser); PrintTicketService.Create(new PrintTicket(LogTypes.AccountResume, serialNo, r.Data1.ToString(), account)); } return(TransactionHelper.CommitAndReturn(r)); } return(new SimpleAjaxResult(Localize("accountNoExisting"))); } catch (System.Exception ex) { Logger.Error(LogTypes.AccountResume, ex); return(new SimpleAjaxResult(ex.Message)); } }
public void Resume(int id) { var item = this.AccountTypeService.GetById(id); if (item != null && item.State == AccountTypeStates.Invalid) { item.State = AccountTypeStates.Normal; AccountTypeService.Update(item); Logger.LogWithSerialNo(LogTypes.AccountTypeResume, SerialNoHelper.Create(), id, item.DisplayName); AddMessage("resume.success", item.DisplayName); CacheService.Refresh(CacheKeys.PointPolicyKey); } }
public void GetAccountTypeControllerTest() { var mockRepository = new Mock <IDeletableEntityRepository <ApplicationUser> >(); mockRepository.Setup(x => x.All()).Returns(this.GetApplicationUserData()); var store = new Mock <IUserStore <ApplicationUser> >(); var userManager = new Mock <UserManager <ApplicationUser> >(store.Object, null, null, null, null, null, null, null, null); var service = new AccountTypeService(userManager.Object, mockRepository.Object); var accountType = service.GetAccountTypeController("1"); Assert.Equal("Candidate", accountType); }
public ResultMsg Suspend(int id) { ResultMsg msg = new ResultMsg(); try { Account item = AccountService.GetById(id); if (item != null && item.State == States.Normal) { item.State = States.Invalid; AccountService.Update(item); Logger.LogWithSerialNo(LogTypes.AccountSuspend, SerialNoHelper.Create(), id, item.Name); if (!string.IsNullOrWhiteSpace(HostSite.MessageTemplateOfAccountSuspend)) { var owner = item.OwnerId.HasValue ? MembershipService.GetUserById(item.OwnerId.Value) : null; if (owner != null && owner.IsMobileAvailable) { var accountType = AccountTypeService.GetById(item.AccountTypeId); if (accountType != null && accountType.IsSmsSuspend) { var msgs = MessageFormator.Format(HostSite.MessageTemplateOfAccountSuspend, owner); msgs = MessageFormator.Format(msgs, item); SmsHelper.Send(owner.Mobile, msgs); } } } msg.Code = 1; msg.CodeText = "停用会员 " + item.Name + " 成功"; // AddMessage("suspend.success", item.Name); } else { msg.CodeText = "不好意思,没有找到会员"; } return(msg); } catch (Exception ex) { msg.CodeText = "不好意思,系统异常"; Logger.Error("停用会员", ex); return(msg); } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var businessService = new BusinessService(_unitOfWork); var business = new Business { Name = model.BusinessName }; businessService.Insert(business); businessService.Save(); var accountNumbering = new AccountNumberingService(_unitOfWork); accountNumbering.InsertDefaultAccountNumbering(business.Id); var accountTypeService = new AccountTypeService(_unitOfWork); accountTypeService.InsertDefaultAccountTypes(business.Id); var accountService = new AccountService(_unitOfWork); accountService.InsertDefaultAccounts(business.Id); var user = new User { UserName = model.Email, Email = model.Email, BusinessId = business.Id }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public void Save() { var serialNo = SerialNoHelper.Create(); var item = AccountTypeService.GetById(AccountTypeId); if (item != null) { item.DisplayName = DisplayName; item.Amount = Amount; //item.DepositAmount = DepositAmount; item.ExpiredMonths = ExpiredMonths; item.Frequency = Frequency; item.NumberOfPeople = NumberOfPeople; item.Describe = Describe; //item.IsRecharging = IsRecharging; //item.IsRenew = IsRenew; //item.RenewMonths = RenewMonths; //item.Point = Point; //var isMessageOfDealBefore = item.IsMessageOfDeal; // item.IsMessageOfDeal = IsMessageOfDeal; //item.IsPointable = this.IsPointable; //item.IsSmsAccountBirthday = IsSmsAccountBirthday; //item.IsSmsClose = IsSmsClose; //item.IsSmsCode = IsSmsCode; //item.IsSmsDeal = IsSmsDeal; //item.IsSmsRecharge = IsSmsRecharge; //item.IsSmsRenew = IsSmsRenew; //item.IsSmsResume = IsSmsResume; //item.IsSmsSuspend = IsSmsSuspend; //item.IsSmsTransfer = IsSmsTransfer; //item.IsSmsChangeName = IsSmsChangeName; TransactionHelper.BeginTransaction(); AccountTypeService.Update(item); AddMessage("success", item.DisplayName); //if (!IsMessageOfDeal && isMessageOfDealBefore) //{ // AccountService.DisableMessageOfDeal(item.AccountTypeId); //} Logger.LogWithSerialNo(LogTypes.AccountTypeEdit, serialNo, item.AccountTypeId, item.DisplayName); TransactionHelper.Commit(); CacheService.Refresh(CacheKeys.PointPolicyKey); } }
public void Ready() { //var q = DistributorService.Query(); //UserRequest user = new UserRequest(); //var users = MembershipService.QueryUsers<DistributorUser>(user).ToList(); //var list = (from x in (q.Where(x => users.Any(u => u.UserId == x.UserId)).ToList()) select new ListDistributor(x) { Owner = users.First(u => u.UserId == x.UserId) }).ToList(); //int distributorId = 0; //var currentUser = this.SecurityHelper.GetCurrentUser(); //if (currentUser is AdminUserModel) //{ // var qq = (from x in list where x.InnerObject.ParentId == distributorId select new IdNamePair { Key = x.DistributorId, Name = x.DisplayName }).ToList(); // qq.Insert(0, new IdNamePair { Key = Ecard.Models.Distributor.Default.DistributorId, Name = Ecard.Models.Distributor.Default.FormatedName }); // Distributor.Bind(qq, true); //} //else if (currentUser is DistributorUserModel) //{ // distributorId = ((DistributorUserModel)currentUser).DistributorId; // var totalId = DistributorService.Query().Select(x => x.DistributorId).ToList(); // var ids = GetChildrenDistributorId(distributorId, totalId); // ids.Add(distributorId); // var qq = (from x in list where ids.Contains(x.DistributorId) select new IdNamePair { Key = x.DistributorId, Name = x.DisplayName }).ToList(); // //qq.Insert(0, new IdNamePair { Key = Ecard.Models.Distributor.Default.DistributorId, Name = Ecard.Models.Distributor.Default.FormatedName }); // Distributor.Bind(qq, true); //} var query = (from x in ShopService.Query(new ShopRequest() { IsBuildIn = false }) select new IdNamePair { Key = x.ShopId, Name = x.FormatedName }).ToList(); //query.Insert(0, new IdNamePair { Key = Ecard.Models.Shop.Default.ShopId, Name = Ecard.Models.Shop.Default.FormatedName }); this.Shop.Bind(query, true); var query1 = (from x in AccountTypeService.Query(new AccountTypeRequest()) select new IdNamePair { Key = x.AccountTypeId, Name = x.DisplayName }).ToList(); //query.Insert(0, new IdNamePair { Key = Ecard.Models.Shop.Default.ShopId, Name = Ecard.Models.Shop.Default.FormatedName }); this.AccountType.Bind(query1, true); }
static void Main(string[] args) { AccountType goldType = new AccountType(0, "Gold", 8, 9); AccountType baseType = new AccountType(1, "Base", 3, 5); AccountType platinumType = new AccountType(2, "Platinum", 15, 13); AccountTypeService typeService = new AccountTypeService(); typeService.AddType(goldType); typeService.AddType(baseType); typeService.AddType(platinumType); Account goldAccount = new Account(0, 0, "Ivan", "Popov"); Account baseAccount = new Account(1, 1, "Denis", "Demenkovets"); Account platinumAccount = new Account(2, 2, "Jack", "Hunter"); IPointsCalculations calculator = new PlusCalculator(); AccountService accountService = new AccountService(typeService, calculator); accountService.AddAccount(goldAccount); accountService.AddAccount(baseAccount); accountService.AddAccount(platinumAccount); PrintAccounts(accountService.GetAccounts()); accountService.PutMoney(2, 10); accountService.WithdrawMoney(2, 5); PrintAccounts(accountService.GetAccounts()); accountService.ChangeCalcLogics(new MultCalculator()); accountService.PutMoney(2, 10); PrintAccounts(accountService.GetAccounts()); typeService.ChangeType(2, 30, 13); accountService.PutMoney(2, 10); PrintAccounts(accountService.GetAccounts()); accountService.SaveAccounts(); typeService.SaveTypes(); Console.ReadKey(); }
public void GetAssetType_WhenProvidedValidInputIsNotActive_ReturnValue_Test() { // Assemble var _fakeAssetTypes = new List <Core.Models.AssetType>() { new Core.Models.AssetType() { Id = 10, Name = "Name 1", IsActive = false } }; _unitOfWork.AssetTypes = new InMemoryAssetTypeRepository(_fakeAssetTypes); var service = new AccountTypeService(_unitOfWork); // Act var result = _service.GetAssetType(_fakeAssetTypes[0].Id); // Assert Assert.IsNull(result, "Result"); }
// GET: Account/Edit/5 public ActionResult Edit(int id) { #region Account Type var accountTypeService = new AccountTypeService(); #endregion #region Customer List var customerService = new CustomerService(); #endregion var model = new AccountModel() { Account = accountService.GetDetails(id), AccountTypeList = accountTypeService.GetSelectList(), CustomerList = customerService.GetSelectList(), }; return(View(model)); }
private IEnumerable <Account> GetAccounts() { int shopId = this.Shop; AccountType accountType = AccountTypeService.GetById(AccountType); if (accountType == null) { yield break; } Shop shop = ShopService.GetById(shopId); for (int i = Start; i <= End; i += Interval) { string password = IsEmptyPassword ? "" : Password; //RandomHelper.GenerateNumber(6); string salt = RandomHelper.GenerateNumber(8); var account = new Account { Name = string.Format(Format, i), Amount = accountType.Amount, Point = accountType.Point, State = AccountStates.Initialized, ExpiredMonths = accountType.ExpiredMonths, InitPassword = password, PasswordSalt = salt, AccountTypeId = accountType.AccountTypeId, DepositAmount = accountType.DepositAmount, Frequency = accountType.Frequency, useScope = shop != null ? shop.Name : "" }; if (shopId != Globals.All) { account.ShopId = shopId; } account.DistributorId = Distributor; account.AccountToken = AccountToken ?? RandomHelper.GenerateNumber(8); account.Password = User.SaltAndHash(account.InitPassword, account.PasswordSalt); account.IsMessageOfDeal = accountType.IsMessageOfDeal; yield return(account); } }
public JsonResult Index(CustomDataTableRequestHelper requestData) { try { #region " [ Declaration ] " AccountTypeService _service = new AccountTypeService(); #endregion #region " [ Main processing ] " // Process sorting column requestData = requestData.SetOrderingColumnName(); #endregion //Call to service Dictionary <string, object> _return = _service.List(requestData, UserID); // if ((ResponseStatusCodeHelper)_return[DatatableCommonSetting.Response.STATUS] == ResponseStatusCodeHelper.OK) { DataTableResponse <AccountTypeModel> itemResponse = _return[DatatableCommonSetting.Response.DATA] as DataTableResponse <AccountTypeModel>; return(this.Json(itemResponse, JsonRequestBehavior.AllowGet)); } // return(this.Json(new DataTableResponse <AccountTypeModel>(), JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, UserID, ex); } }
public void Delete(int id) { var item = this.AccountTypeService.GetById(id); if (item != null) { if (AccountService.Query(new AccountRequest() { AccountTypeId = item.AccountTypeId }).Count() > 0) { AddError("delete.existAccount"); } else { AccountTypeService.Delete(item); Logger.LogWithSerialNo(LogTypes.AccountTypeDelete, SerialNoHelper.Create(), item.AccountTypeId, item.DisplayName); AddMessage("delete.success", item.DisplayName); } CacheService.Refresh(CacheKeys.PointPolicyKey); } }