private static Domain.Models.Customer MapToDomain( Entities.Customer entityCustomer) { return(new Domain.Models.Customer( customerId: entityCustomer.CustomerId, age: entityCustomer.Age)); }
public async Task <Customer> Get(Guid id) { using (IDbConnection db = new SqlConnection(_connectionString)) { string customerSQL = "SELECT * FROM Customer WHERE Id = @Id"; Entities.Customer customer = await db .QueryFirstOrDefaultAsync <Entities.Customer>(customerSQL, new { id }); if (customer == null) { return(null); } string accountSQL = "SELECT * FROM Account WHERE CustomerId = @Id"; IEnumerable <Guid> accounts = await db .QueryAsync <Guid>(accountSQL, new { id }); AccountCollection accountCollection = new AccountCollection(); foreach (Guid accountId in accounts) { accountCollection.Add(accountId); } Customer result = Customer.Load( customer.Id, customer.Name, customer.Aadhar, accountCollection); return(result); } }
public async Task <SaveCustomerResponse> UpdateAsync(long id, SaveCustomerRequest request) { var existing = await repository.GetAsync(id); if (existing == null) { throw new NotFoundException(); } if (existing.IsDeleted) { throw new GoneException(); } Entities.Customer customer = new Entities.Customer { Id = id, Name = request.Name, SourceId = request.SourceId, IndustryCodes = request.IndustryCodes, UpdatedBy = await identityResolver.GetUserNameAsync(), Updated = DateTime.UtcNow, Created = existing.Created, CreatedBy = existing.CreatedBy }; var resultId = await repository.UpdateAsync(customer); return(new SaveCustomerResponse { Id = resultId }); }
public Entities.Customer GetCustomer(long id) { Entities.Customer found = null; try { var item = context.Customers.FirstOrDefault(i => i.Id_User == id); if (item != null) { found = new Entities.Customer() { User = new Entities.User() { Id = item.Id_User, Username = item.Users.Username }, Address = item.Address, Fullname = item.Fullname, PhoneNumer = item.PhoneNumer }; } return found; } finally { found = null; } }
/// <summary> /// Set the Customer Test Data /// </summary> /// <returns></returns> private List <Entities.Customer> GetCustomerTestData() { var firstCustomer = new Entities.Customer { Code = "1", Name = "TestCustomer1", Phone = "12345", CL_Status = "A" }; var secondCustomer = new Customer { Code = "2", Name = "TestCustomer2", Phone = "543221", CL_Status = "A", Loyalty_Code = "777" }; var customers = new List <Customer>() { firstCustomer, secondCustomer }; return(customers); }
public void SearchArCardIfCardStatusIsENotVTest() { var customer = new Entities.Customer(); var strExp = string.Empty; MessageStyle message; var cardNumber = "12345"; var expected = "Card is Expired."; var customerCode = "1"; var getClient = GetClientCardTestData(); var getCustomer = GetCustomerTestData(); var getClientByCardNumber = getClient.FirstOrDefault(x => x.CardNumber == cardNumber); _customerService.Setup(x => x.GetClientCardByCardNumber(It.IsAny <string>())) .Returns(getClientByCardNumber); getClientByCardNumber.CardStatus = 'E'; var getCustomerByCode = getCustomer.FirstOrDefault(x => x.Code == customerCode); _customerService.Setup(x => x.GetClientByClientCode(It.IsAny <string>())) .Returns(getCustomerByCode); //_resourceManager.Setup(x => x.CreateErrorMessage(It.IsAny<short>(), It.IsAny<object>())) // .Returns("Card Status type is E"); _customerManager = new CustomerManager(_customerService.Object, _policyManager.Object, _resourceManager, _creditCardCardManager.Object); var actual = _customerManager.SearchCustomerCard(cardNumber, false, out message); Assert.AreEqual(expected, message.Message); }
public async Task <ActionResult> Post([FromBody] Models.Customer model) { Entities.Customer customer; if (!model.Id.HasValue) { customer = new Entities.Customer { Contact = new Contact { AddDate = DateTime.UtcNow, } }; _repository.Customers.Add(customer); } else { customer = await _repository.Customers.FirstOrDefaultAsync(p => p.ContactId == model.Id); } customer.Contact.FirstName = model.FirstName; customer.Contact.LastName = model.LastName; customer.Contact.Title = model.Title; customer.CustomerType = (CustomerType)model.CustomerTypeId; customer.Notes = model.Notes; customer.PrimaryActivity = _repository.Activities.FirstOrDefault(p => p.Id == model.PrimaryActivityId); customer.PrimaryDestination = _repository.Destinations.FirstOrDefault(p => p.Id == model.PrimaryDestinationId); customer.Contact.ModifiedDate = DateTime.UtcNow; _repository.Save(); return(Ok()); }
public Domain.Models.Customer Update(Domain.Models.Customer updated) { Entities.Customer mappedCust = mapper.Map(updated, context, true); context.SaveChanges(); //context.ChangeTracker.Clear(); return(mapper.Map(mappedCust)); }
public void NewCustomerIsValid() { IResult <Entities.Customer> customerResult = null; Entities.Customer customerActual = null; try { customerResult = _mock.Object.Add(_customerToAddValid); customerActual = customerResult.Data; } catch (System.Exception ex) { StaticExceptionFail.New(ex); } Assert.IsNotNull(customerResult); Assert.AreEqual(true, customerResult.Success); Assert.IsNotNull(customerActual); Assert.AreEqual(_customerToAddValid.Id, customerActual.Id); Assert.AreEqual(_customerToAddValid.Name, customerActual.Name); Assert.AreEqual(_customerToAddValid.Email, customerActual.Email); Assert.AreEqual(_customerToAddValid.Telephone, customerActual.Telephone); Assert.AreEqual(_customerToAddValid.BirthDate.Date, customerActual.BirthDate.Date); }
public async Task <IActionResult> Create(Entities.Customer customer) { _context.Customers.Add(customer); await _context.SaveChanges(); return(Ok(customer.Id)); }
public void UpdateCustomer(Entities.Customer customer, string name, string surname, string phoneNumber, string email) { customer.PersonalInfo.Name = name; customer.PersonalInfo.Surname = surname; customer.PersonalInfo.PhoneNumber = phoneNumber; customer.PersonalInfo.Email = email; }
public async Task <Customer> Get(Guid id) { Entities.Customer customer = await _context.Customers. Find(customer => customer.Id == id) .SingleOrDefaultAsync(); List <Guid> accountIds = await _context .Accounts .Find(account => account.CustomerId == id) .Project(p => p.Id) .ToListAsync(); AccountCollection accountCollection = new AccountCollection(); foreach (var accountId in accountIds) { accountCollection.Add(accountId); } return(Customer.Load( customer.Id, customer.Name, customer.Aadhar, accountCollection)); }
public static void CustomerNull(this IGuardClause guardClause, Entities.Customer customer, string accountNumber) { if (customer == null) { throw new CustomerNotFoundException(accountNumber); } }
public async Task Handle_ExistingCustomerAndAddress_DeleteCustomerAddress( [Frozen] Entities.Customer customer, [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock, DeleteCustomerAddressCommandHandler sut, DeleteCustomerAddressCommand command, Entities.Address address ) { //Arrange customer.AddAddress( new Entities.CustomerAddress( command.AddressType, address ) ); customerRepoMock.Setup(x => x.GetBySpecAsync( It.IsAny <GetCustomerSpecification>(), It.IsAny <CancellationToken>() )) .ReturnsAsync(customer); //Act var result = await sut.Handle(command, CancellationToken.None); //Assert result.Should().NotBeNull(); customerRepoMock.Verify(x => x.UpdateAsync( It.IsAny <Entities.Customer>(), It.IsAny <CancellationToken>() )); }
public async Task <bool> Update(Entities.Customer customer) { var result = await _context.Customers .ReplaceOneAsync(filter : c => c.Id == customer.Id, replacement : customer); return(result.IsAcknowledged && result.ModifiedCount > 0); }
public async Task <CustomerResult> GetCustomer(Guid customerId) { using (IDbConnection db = new SqlConnection(_connectionString)) { string customerSQL = "SELECT * FROM Customer WHERE Id = @customerId"; Entities.Customer customer = await db .QueryFirstOrDefaultAsync <Entities.Customer>(customerSQL, new { customerId }); if (customer == null) { return(null); } string accountSQL = "SELECT id FROM Account WHERE CustomerId = @customerId"; IEnumerable <Guid> accounts = await db .QueryAsync <Guid>(accountSQL, new { customerId }); List <AccountResult> accountCollection = new List <AccountResult>(); foreach (Guid accountId in accounts) { accountCollection.Add(await _accountsQueries.GetAccount(accountId)); } CustomerResult customerResult = new CustomerResult(customer.Id, customer.Name, customer.SSN, accountCollection); return(customerResult); } }
public async Task <Entities.Customer> UpdateCustomerAysnc(Entities.Customer customer) { var res = await _unitOfWork.customerRepository.UpdateAsync(customer); //_unitOfWork.CustomerRepo.SaveChangesAsync(); return(res); }
public async Task <CustomerResult> GetCustomer(Guid customerId) { Entities.Customer customer = await _context .Customers .FindAsync(customerId); List <Entities.Account> accounts = await _context .Accounts .Where(e => e.CustomerId == customerId) .ToListAsync(); if (customer == null) { throw new CustomerNotFoundException($"The customer {customerId} does not exists or is not processed yet."); } List <AccountResult> accountsResult = new List <AccountResult>(); foreach (Account account in accounts) { AccountResult accountResult = await _accountsQueries.GetAccount(account.Id); accountsResult.Add(accountResult); } CustomerResult customerResult = new CustomerResult( customer.Id, customer.Name, customer.SSN, accountsResult); return(await Task.FromResult <CustomerResult>(customerResult)); }
public void RecalculateCustomerGrade(Entities.Customer customer, decimal grade) { var rideCount = customer.Rides.Count; var gradesSum = customer.SystemInfo.Grade * (rideCount - 1); var newGrade = (gradesSum + grade) / rideCount; customer.UpdateGrade(newGrade); }
public static void CustomerNull(this IGuardClause guardClause, Entities.Customer input, string customerNumber, ILogger logger) { if (input == null) { logger.LogInformation($"Customer {customerNumber} not found"); throw new CustomerNotFoundException(); } }
public void Map_CustomerAddressTypes() { var source = new Entities.Customer(); var target = EfMapper.Map <Entities.Customer, Customer>(source); target.MainAddress.AddressType.ShouldEqual(AddressType.Main); target.MailingAddress.AddressType.ShouldEqual(AddressType.Mailing); target.OtherAddress.AddressType.ShouldEqual(AddressType.Other); }
public async Task Add(Customer customer) { Entities.Customer customerEntity = new Entities.Customer { Id = customer.Id, Name = customer.Name, Aadhar = customer.Aadhar, }; await _context.Customers.InsertOneAsync(customerEntity); }
public Models.Customer ParseCustomer(Entities.Customer customer) { return(new Models.Customer() { Name = customer.Name, Password = customer.Password, Address = customer.Address, Id = customer.Id }); }
public async void Remove(Customer customer) { Entities.Customer dbCustomer = await _viFlixContext.Customers.FindAsync(customer.Id); if (dbCustomer == null) { return; } _viFlixContext.Customers.Remove(dbCustomer); }
private void OnCustomerBindingSourceCurrentItemChanged(object sender, System.EventArgs e) { _currentCustomer = uxCustomerBindingSource.Current as Entities.Customer; if (_currentCustomer != null) { _currentCustomer.Validate(); } //_Customer.Validate(); OnCurrentEntityChanged(); }
public Entities.Customer GenerateCustomerValid() { var customer = new Entities.Customer() { CustomerID = Guid.NewGuid(), Name = "Tiago", Email = "teste@teste" }; return(customer); }
public Entities.Customer GenerateCustomerInvalid() { var customer = new Entities.Customer() { CustomerID = Guid.Empty, Name = "", Email = "" }; return(customer); }
public async Task <Customer> GetCustomerWithMembershipTypeAsync(int id) { Entities.Customer dbCustomer = await _viFlixContext.Customers.Include(c => c.MembershipType).SingleOrDefaultAsync(c => c.Id == id); if (dbCustomer == null) { return(new Customer()); } return(Converter.ToModelCustomer(dbCustomer)); }
public static Customer MapCustomer(Entities.Customer customer) { return(new Customer { CustomerId = customer.CustomerId, FirstName = customer.FirstName, LastName = customer.LastName, FavoriteStore = customer.FavoriteStore, PhoneNumber = customer.PhoneNumber, }); }
public async Task <Customer> GetAsync(object id) { Entities.Customer dbCustomer = await _viFlixContext.Customers.FindAsync(id); if (dbCustomer == null) { return(new Customer()); } return(Converter.ToModelCustomer(dbCustomer)); }
public async Task Update(Customer customer) { Entities.Customer customerEntity = new Entities.Customer() { Id = customer.Id, Name = customer.Name, SSN = customer.SSN }; await _context.Customers .ReplaceOneAsync(e => e.Id == customer.Id, customerEntity); }