/// <summary> /// Initializes a new instance of the <see cref="CatalogController" /> class. /// </summary> /// <param name="inventoryManager">The inventory manager.</param> /// <param name="contactFactory">The contact factory.</param> /// <param name="accountManager">The account manager.</param> /// <param name="catalogManager">The catalog manager.</param> /// <param name="giftCardManager">The gift card manager.</param> public CatalogController( [NotNull] InventoryManager inventoryManager, [NotNull] ContactFactory contactFactory, [NotNull] AccountManager accountManager, [NotNull] CatalogManager catalogManager, [NotNull] GiftCardManager giftCardManager) : base(accountManager, contactFactory) { Assert.ArgumentNotNull(inventoryManager, "inventoryManager"); Assert.ArgumentNotNull(catalogManager, "catalogManager"); Assert.ArgumentNotNull(giftCardManager, "giftCardManager"); this.InventoryManager = inventoryManager; this.CatalogManager = catalogManager; this.GiftCardManager = giftCardManager; }
private void InsertButton_Click(object sender, RoutedEventArgs e) { #region validation ForceValidation(); if (Validation.GetHasError(NameTextBox) || Validation.GetHasError(AddressTextBox) || Validation.GetHasError(EmailTextBox) || Validation.GetHasError(PhoneNoTextBox)) { var sMessageDialog = new MessageDialog { Message = { Text = "ERROR: Fill required fields!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } #endregion Contact comp = new Contact(); comp.CompanyName = NameTextBox.Text; comp.Phone = PhoneNoTextBox.Text; comp.Email = EmailTextBox.Text; comp.Address = AddressTextBox.Text; ContactFactory fac = new ContactFactory(); if (fac.InsertContact(comp)) { var sMessageDialog = new MessageDialog { Message = { Text = "Inserted Successfully!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); Clear(); return; } else { var sMessageDialog = new MessageDialog { Message = { Text = "Not Inserted.." } }; DialogHost.Show(sMessageDialog, "RootDialog"); Clear(); return; } }
public ActionResult Create( [Bind(Include = "ContactId,PhoneNumber,Email,DisplayNumber,Password")] Contact contact, FormCollection collectedValues) { var loggedinuser = Session["gotitbackloggedinuser"] as Contact; if (ModelState.IsValid) { if (loggedinuser == null) { contact.CreatedBy = 0; contact.LastModifiedBy = 0; contact.Role = Usertype.Client.ToString(); } else { contact.Role = typeof(Usertype).GetEnumName(int.Parse(collectedValues["Role"])); } var password = collectedValues["Password"]; var confirmPassword = collectedValues["ConfirmPassword"]; contact.DateCreated = DateTime.Now; contact.DateLastModified = DateTime.Now; if (password == confirmPassword) { contact.Password = new Md5Ecryption().ConvertStringToMd5Hash(confirmPassword); } else { TempData["wrongPassword"] = "******"; return(View(contact)); } var userExist = new ContactFactory().CheckIfUserExist(collectedValues["Email"]); if (userExist) { TempData["saveContact"] = "A registerged user has this email,Change the email and try again!"; return(View(contact)); } db.Contacts.Add(contact); db.SaveChanges(); TempData["saveContact"] = "Make sure the password field and confirm password are the same!"; return(RedirectToAction("Index")); } return(View(contact)); }
public async Task AddSampleData() { var client = await EnsureClientCreated(); foreach (var contact in ContactFactory.GetContactList(30)) { var newContact = new Microsoft.Office365.Exchange.Contact { GivenName = contact.GivenName, Surname = contact.Surname, CompanyName = contact.CompanyName, EmailAddress1 = contact.EmailAddress1, BusinessPhone1 = contact.BusinessPhone1, HomePhone1 = contact.HomePhone1 }; await client.Me.Contacts.AddContactAsync(newContact); } }
/// <summary> /// Initializes a new instance of the <see cref="CartsServiceTest"/> class. /// </summary> public CartsServiceTest() { this.cart = new Cart(); this.cartFromAnonymous = new Cart(); this.result = new CartResult { Cart = this.cart }; this.resultFromAnonymous = new CartResult { Cart = this.cartFromAnonymous }; this.cartServiceProvider = Substitute.For <CartServiceProvider>(); this.cartServiceProvider.CreateOrResumeCart(Arg.Is <CreateOrResumeCartRequest>(r => r.UserId == "John Carter")).Returns(this.result); var pricesResult = new GetProductPricesResult(); pricesResult.Prices.Add("List", new Price(0, "USD")); this.pricingService = Substitute.For <PricingServiceProvider>(); this.pricingService.GetProductPrices(Arg.Any <GetProductPricesRequest>()).Returns(pricesResult); this.contactId = Guid.NewGuid(); this.cartServiceProvider.CreateOrResumeCart(Arg.Is <CreateOrResumeCartRequest>(r => r.UserId == ID.Parse(this.contactId).ToString())).Returns(this.resultFromAnonymous); this.cartServiceProvider.GetCarts(Arg.Any <GetCartsRequest>()).Returns(new GetCartsResult { Carts = Enumerable.Empty <CartBase>() }); this.contactFactory = Substitute.For <ContactFactory>(); this.contactFactory.GetContact().Returns("John Carter"); var inventoryResult = new GetStockInformationResult(); inventoryResult.StockInformation.ToList().Add(new StockInformation { Product = new InventoryProduct { ProductId = "1001" }, Status = StockStatus.InStock }); this._inventoryService = Substitute.For <InventoryServiceProvider>(); this._inventoryService.GetStockInformation(Arg.Any <GetStockInformationRequest>()).Returns(inventoryResult); this._customerService = Substitute.For <CustomerServiceProvider>(); this._wishListServiceProvider = Substitute.For <WishListServiceProvider>(); this.service = new CartService(this.cartServiceProvider, this._wishListServiceProvider, this.pricingService, "autohaus", this.contactFactory, this._inventoryService, this._customerService); }
public PipelineExecutionResult Execute(PurchaseOrder purchaseOrder) { var contactRepositoryBase = Assert.ResultNotNull(Factory.CreateObject("contactRepository", true) as ContactRepositoryBase); var contactFactory = new ContactFactory(); string userIdentifier = contactFactory.GetContact(); var leaseOwner = new LeaseOwner(AnalyticsSettings.ClusterName, LeaseOwnerType.WebCluster); var contact = CommerceAutomationHelper.GetContact(userIdentifier); if (contact != null) { AddEmailAddressToContact(purchaseOrder, contact); contactRepositoryBase.SaveContact(contact, new ContactSaveOptions(true, leaseOwner, new TimeSpan?())); } return(PipelineExecutionResult.Success); }
/// <summary> /// Initializes a new instance of the <see cref="WishListController" /> class. /// </summary> /// <param name="inventoryManager">The inventory manager.</param> /// <param name="accountManager">The account manager.</param> /// <param name="wishListManager">The wish list manager.</param> /// <param name="contactFactory">The contact factory.</param> /// <param name="storefrontContext"></param> /// <param name="commerceUserContext"></param> public WishListController( [NotNull] InventoryManager inventoryManager, [NotNull] AccountManager accountManager, [NotNull] WishListManager wishListManager, [NotNull] ContactFactory contactFactory, StorefrontContext storefrontContext, CommerceUserContext commerceUserContext) : base(accountManager, contactFactory) { Assert.ArgumentNotNull(contactFactory, "contactFactory"); Assert.ArgumentNotNull(inventoryManager, "inventoryManager"); Assert.ArgumentNotNull(wishListManager, "wishListManager"); this.InventoryManager = inventoryManager; this.WishListManager = wishListManager; this.StorefrontContext = storefrontContext; this.CommerceUserContext = commerceUserContext; }
/// <summary> /// Initializes a new instance of the <see cref="CheckoutController" /> class. /// </summary> /// <param name="cartManager">The cart manager.</param> /// <param name="orderManager">The order manager.</param> /// <param name="accountManager">The account manager.</param> /// <param name="paymentManager">The payment manager.</param> /// <param name="shippingManager">The shipping manager.</param> /// <param name="contactFactory">The contact factory.</param> public CheckoutController( [NotNull] CartManager cartManager, [NotNull] OrderManager orderManager, [NotNull] AccountManager accountManager, [NotNull] PaymentManager paymentManager, [NotNull] ShippingManager shippingManager, [NotNull] ContactFactory contactFactory) : base(accountManager, contactFactory) { Assert.ArgumentNotNull(cartManager, "cartManager"); Assert.ArgumentNotNull(orderManager, "orderManager"); Assert.ArgumentNotNull(paymentManager, "paymentManager"); Assert.ArgumentNotNull(shippingManager, "shippingManager"); this.CartManager = cartManager; this.OrderManager = orderManager; this.PaymentManager = paymentManager; this.ShippingManager = shippingManager; }
public async Task CreateContact_Command_should_return_new_Contact() { // Arrange var context = DbContextFactory.CreateContext(); var validator = new ContactValidator(); var contactModel = ContactFactory.GetContactModel(0); var command = new CreateContactCommand(contactModel); var handler = new CreateContactCommandHandler(context, validator, _mapper); // Act var result = await handler.Handle(command, new CancellationToken()); // Assert Assert.IsNotNull(result); Assert.IsTrue(result.IsSuccessful); Assert.IsTrue(result.Id > 0); }
public PipelineExecutionResult Execute(PurchaseOrder subject) { var cartServiceProvider = new CartServiceProvider(); var contactFactory = new ContactFactory(); string userId = contactFactory.GetContact(); var createCartRequest = new CreateOrResumeCartRequest(Context.GetSiteName(), userId); var cart = cartServiceProvider.CreateOrResumeCart(createCartRequest).Cart; var orderService = new OrderServiceProvider(); var request = new SubmitVisitorOrderRequest(cart); // Pass the PurchaseOrder object to Commerce Connect, so it can set use the data for // the page events, etc. request.Properties.Add("UCommerceOrder", subject); var result = orderService.SubmitVisitorOrder(request); return(PipelineExecutionResult.Success); }
public static IServiceCollection AddDataAccessModule(this IServiceCollection services, IConfiguration configuration) { var numberOfContacts = configuration.GetValue("numberOfContacts", 100); var allowedRange = ContactFactory.NumberOfContactsRange; if (numberOfContacts.IsNotIn(allowedRange)) { throw new InvalidConfigurationException($"{nameof(numberOfContacts)} must be between {allowedRange.From} and {allowedRange.To}, but you provided {numberOfContacts}. Please adjust appsettings.json."); } var options = new DbContextOptionsBuilder <DatabaseContext>().UseInMemoryDatabase("Contacts") .Options; var contacts = ContactFactory.GenerateFakeData(numberOfContacts); using var context = new DatabaseContext(options); context.Contacts.AddRange(contacts); context.SaveChanges(); return(services.AddTransient <DatabaseContext>() .AddSingleton <DbContextOptions>(options)); }
/// <summary> /// Метод создания базовых реквизитов /// </summary> /// <param name="lastName">фамилия</param> /// <param name="firstName">имя</param> /// <param name="middleName">отчество</param> /// <param name="series">серия</param> /// <param name="number">номер</param> /// <param name="address">адрес</param> /// <param name="phoneNumber">номер телефона</param> /// <param name="email">эмейл</param> /// <param name="cardName">наименование карты</param> /// <param name="accountType">тип аккаунта</param> /// <returns>паспортные данные, контактные данные, аккаунт</returns> private static (Passport passport, Contact contact, Account account) CreateBaseRequisites(string lastName, string firstName, string middleName, string series, string number, string address, string phoneNumber, string email, string cardName, AccountType accountType) { //Паспортные данные var fullName = FullNameFactory.CreateFullName(lastName, firstName, middleName); var seriesAndNumber = SeriesAndNumberFactory.CreateSeriesAndNumber(series, number); var passport = PassportFactory.CreatePassport(fullName, seriesAndNumber, address); //Контактные данные var phone = PhoneNumberFactory.CreateNumber(phoneNumber); var contact = ContactFactory.CreateContact(phone, email); //Данные аккаунта var card = SimpleCardFactory.CreateCard(cardName, default); var deposit = new NullDeposit(); var account = SimpleAccountFactory.CreateAccount(accountType, card, deposit); return(passport, contact, account); }
/// <summary> /// Initializes a new instance of the <see cref="CartController" /> class. /// </summary> /// <param name="cartManager">The cart manager.</param> /// <param name="accountManager">The account manager.</param> /// <param name="contactFactory">The contact factory.</param> public CartController([NotNull] CartManager cartManager, [NotNull] AccountManager accountManager, [NotNull] ContactFactory contactFactory) : base(accountManager, contactFactory) { Assert.ArgumentNotNull(cartManager, "cartManager"); CartManager = cartManager; AccountManager = accountManager; }
/// <summary> /// Initializes a new instance of the <see cref="NavigationSearchController"/> class. /// </summary> /// <param name="contactFactory">The contact factory.</param> public NavigationSearchController([NotNull] ContactFactory contactFactory) : base(contactFactory) { }
/// <summary> /// Initializes a new instance of the <see cref="BaseController"/> class. /// </summary> /// <param name="contactFactory">The contact factory.</param> public BaseController(ContactFactory contactFactory) { Assert.ArgumentNotNull(contactFactory, "contactFactory"); this._contactFactory = contactFactory; }
/// <summary> /// Initializes a new instance of the <see cref="InventoryManager" /> class. /// </summary> /// <param name="inventoryServiceProvider">The inventory service provider.</param> /// <param name="contactFactory">The contact factory.</param> public InventoryManager([NotNull] InventoryServiceProvider inventoryServiceProvider, [NotNull] ContactFactory contactFactory) { Assert.ArgumentNotNull(inventoryServiceProvider, "inventoryServiceProvider"); Assert.ArgumentNotNull(contactFactory, "contactFactory"); this.InventoryServiceProvider = inventoryServiceProvider; this.ContactFactory = contactFactory; this._obecContext = (CommerceContextBase)Factory.CreateObject("commerceContext", true); }
/// <summary> /// Initializes a new instance of the <see cref="AxBaseController"/> class. /// </summary> /// <param name="accountManager">The account manager.</param> /// <param name="contactFactory">The contact factory.</param> public AxBaseController(AccountManager accountManager, ContactFactory contactFactory) : base() { this.AccountManager = accountManager; }
public JsonResult GetProjectContactsByCustomerGuid(string guid) { var re = new ContactFactory().GetAllContacts().Where(c => c.CustomerGuid.Equals(guid)).ToList(); return(Json(new { result = 1, dataList = re }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Initializes a new instance of the <see cref="VisitorContext"/> class. /// </summary> /// <param name="contactFactory">The contact factory.</param> public VisitorContext([NotNull] ContactFactory contactFactory) { Assert.ArgumentNotNull(contactFactory, "contactFactory"); this.ContactFactory = contactFactory; }
/// <summary> /// Initializes a new instance of the <see cref="InventoryService"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="contactFactory">The visitor factory.</param> public InventoryService(InventoryServiceProvider serviceProvider, ContactFactory contactFactory) { this._serviceProvider = serviceProvider; this._contactFactory = contactFactory; }
public void Setup() { this.factory = new ContactFactory(); }
public CommerceUser(ContactFactory contactFactory) { Assert.ArgumentNotNull(contactFactory, nameof(contactFactory)); ContactFactory = contactFactory; }
public GetContactsSessionMock(int numberOfContacts) { Contacts = ContactFactory.GenerateFakeData(numberOfContacts); }
public CommerceContactFactory() { _contactFactory = new ContactFactory(); }
/// <summary> /// Initializes a new instance of the <see cref="CartService" /> class. /// </summary> /// <param name="cartServiceProvider">The service provider.</param> /// <param name="wishListServiceProvider">The wish list service provider.</param> /// <param name="pricingServiceProvider">The pricing service provider.</param> /// <param name="shopName">Name of the shop.</param> /// <param name="contactFactory">The visitor factory.</param> /// <param name="inventoryServiceProvider">The inventory service provider.</param> /// <param name="customerServiceProvider">The customer service provider.</param> public CartService([NotNull] CartServiceProvider cartServiceProvider, [NotNull] WishListServiceProvider wishListServiceProvider, [NotNull] PricingServiceProvider pricingServiceProvider, [NotNull] string shopName, ContactFactory contactFactory, [NotNull] InventoryServiceProvider inventoryServiceProvider, [NotNull] CustomerServiceProvider customerServiceProvider) { Assert.ArgumentNotNull(cartServiceProvider, "cartServiceProvider"); Assert.ArgumentNotNull(wishListServiceProvider, "wishListServiceProvider"); Assert.ArgumentNotNull(pricingServiceProvider, "pricingServiceProvider"); Assert.ArgumentNotNull(customerServiceProvider, "customerServiceProvider"); Assert.ArgumentNotNullOrEmpty(shopName, "shopName"); this._cartServiceProvider = cartServiceProvider; this._pricingServiceProvider = pricingServiceProvider; this.shopName = shopName; this.contactFactory = contactFactory; this._inventoryServiceProvider = inventoryServiceProvider; this._customerServiceProvider = customerServiceProvider; this._wishListServiceProvider = wishListServiceProvider; }
/// <summary> /// Initializes a new instance of the <see cref="SharedController"/> class. /// </summary> /// <param name="contactFactory">The contact factory.</param> public SharedController(ContactFactory contactFactory) : base(contactFactory) { _model = new RenderingModel(); }
/// <summary> /// Initializes a new instance of the <see cref="LandingController"/> class. /// </summary> /// <param name="accountManager">The account manager.</param> /// <param name="inventoryManager">The inventory manager.</param> /// <param name="contactFactory">The contact factory.</param> public LandingController([NotNull] AccountManager accountManager, [NotNull] InventoryManager inventoryManager, [NotNull] ContactFactory contactFactory) : base(accountManager, contactFactory) { Assert.ArgumentNotNull(inventoryManager, "inventoryManager"); this.InventoryManager = inventoryManager; }
public AccountManager(CartManager cartManager, CustomerServiceProvider customerServiceProvider, ContactFactory contactFactory, MailManager mailManager, StorefrontContext storefrontContext) { CustomerServiceProvider = customerServiceProvider; ContactFactory = contactFactory; MailManager = mailManager; StorefrontContext = storefrontContext; this.CartManager = cartManager; }
/// <summary> /// Метод заполнения репозитория клиентами /// </summary> /// <param name="dbContext">контекст данных</param> /// <param name="quantity">кол-во клиентов</param> private static void FillRepository(AppDbContext dbContext, int quantity) { Parallel.For(1, quantity + 1, (i) => { lock (locker) { Client client = null; decimal cardBalance = random.Next(1, 10) * 10000; decimal depositBalance = random.Next(1, 10) * 10000; bool capitalization = Convert.ToBoolean(random.Next(2)); //Паспортные данные var passport = PassportFactory.CreatePassport( FullNameFactory.CreateFullName(Gender.Female), SeriesAndNumberFactory.CreateSeriesAndNumber(), $"Адрес_{i}"); //Контактные данные var contact = ContactFactory.CreateContact(PhoneNumberFactory.CreateNumber(), $"Client@Email_{i}.ru"); switch (random.Next(Enum.GetNames(typeof(ClientType)).Length)) { case (int)ClientType.Individual: //Данные аккаунта var card = IndividualsCardFactories[random.Next(IndividualsCardFactories.Length)].CreateCard(cardBalance); var deposit = random.Next(2) == 0 ? new DefaultDepositFactory().CreateDeposit(depositBalance, capitalization, ClientType.Individual) : new NullDeposit(); var individualAccount = AccountFactories[random.Next(AccountFactories.Length)].CreateAccount(card, deposit); //Создание физ. лица client = IndividualFactory.CreateIndividual(passport, contact, individualAccount); break; case (int)ClientType.Entity: //Данные аккаунта card = EntitiesCardFactories[random.Next(EntitiesCardFactories.Length)].CreateCard(cardBalance); deposit = random.Next(2) == 0 ? new DefaultDepositFactory().CreateDeposit(depositBalance, capitalization, ClientType.Entity) : new NullDeposit(); var entityAccount = AccountFactories[random.Next(AccountFactories.Length)].CreateAccount(card, deposit); //Данные компании var company = CompanyFactory.CreateCompany($"Компания_{i}", $"http:\\Company.Website_{i}.ru"); //Создание юр.лица client = EntityFactory.CreateEntity(passport, contact, entityAccount, company); break; default: throw new ArgumentOutOfRangeException(); } ProcessingCountEvent?.Invoke(Count++); dbContext.Add(client); } }); dbContext.SaveChanges(); }
/// <summary> /// Initializes a new instance of the <see cref="AccountManager" /> class. /// </summary> /// <param name="cartManager">The cart manager.</param> /// <param name="customerServiceProvider">The customer service provider.</param> /// <param name="contactFactory">The contact factory.</param> public AccountManager(CartManager cartManager, [NotNull] CustomerServiceProvider customerServiceProvider, [NotNull] ContactFactory contactFactory) { Assert.ArgumentNotNull(customerServiceProvider, "customerServiceProvider"); Assert.ArgumentNotNull(contactFactory, "contactFactory"); this.CartManager = cartManager; this.CustomerServiceProvider = customerServiceProvider; this.ContactFactory = contactFactory; }