Example #1
0
        public ActionResult EditCustomer(CreateCustomer create)
        {
            Customer    cust        = db.Customer.Find(create.CustomerID);
            Address     address     = db.Address.Find(create.AddressID);
            PaymentInfo paymentInfo = db.PaymentInfo.Find(create.PaymentInfoID);
            Login       login       = db.Login.Find(create.LoginID);

            if (create != null)
            {
                cust.CustFirstName = create.CustFirstName;
                cust.CustLastName  = create.CustLastName;
                cust.CustEmail     = create.CustEmail;


                address.StreetAddress1 = create.StreetAddress1;
                address.StreetAddress2 = create.StreetAddress2;
                address.Country        = create.Country;
                address.City           = create.City;
                address.State          = create.State;
                address.Zip            = create.Zip;

                paymentInfo.Last4Digits = create.Last4Digits;

                login.Password = create.Password;


                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
        static void Main(string[] args)
        {
            string             prodPath = System.Environment.GetEnvironmentVariable("BANGAZON_CLI_DB");
            DatabaseConnection db       = new DatabaseConnection(prodPath);

            DatabaseStartup databaseStartup = new DatabaseStartup(db);
            MainMenu        menu            = new MainMenu();
            CustomerManager cm = new CustomerManager(db);

            int choice;

            // When the user enters the system show the main menu
            do
            {
                choice = menu.Show();

                switch (choice)
                {
                case 1:
                    // Displays the Create Customer Menu
                    CreateCustomer.CreateCustomerMenu(cm);
                    break;
                }
            }while (choice != 9);
            menu.Show();
        }
        public void WhenICreateANewCustomerWithTheFollowingDetails(Table table)
        {
            var values = table.Rows.Single();

            _uiViewInfo = new CustomerUiViewInfo(
                values["Title"],
                values["Name"],
                values["Address Line 1"],
                values["Address Line 2"],
                values["Address Line 3"],
                values["Postcode"],
                values["Home Phone"],
                values["Mobile"]);

            _actor.AttemptsTo(
                Navigate.To(CustomerMaintenancePage.Path),
                CreateCustomer.Named(values["Name"])
                .Titled(values["Title"])
                .OfAddress(
                    values["Address Line 1"],
                    values["Address Line 2"],
                    values["Address Line 3"],
                    values["Postcode"])
                .WithHomePhone(values["Home Phone"])
                .WithMobile(values["Mobile"]));
        }
        public async Task <IActionResult> Post(CreateCustomer command)
        {
            var context = GetContext(command.Id);
            await BusPublisher.SendAsync(command, context);

            return(Accepted());
        }
        private void Execute(CreateCustomer command)
        {
            var customer = _aggregateEventStore.GetAggregate <Customer>(command.Id);

            customer.Create(command.Id, command.Name);
            _aggregateEventStore.Save(customer);
        }
Example #6
0
        public void CreateCustomer_Action_Fails()
        {
            // Arrange
            var customerDto = TestHelper.CustomerDto();

            GenericServiceResponse <bool> fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.CustomerService.CreateCustomer(customerDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new CreateCustomer <GenericViewModel>(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke(customerDto);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericViewModel));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Success);
            Assert.IsInstanceOfType(result.Success, typeof(bool));
            Assert.IsFalse(result.Success);
        }
Example #7
0
        public void UpdateCustomerTest()
        {
            string authorization = "Basic asdadsa";
            string customerId    = "2345";

            mockRestClient.Expects.One.Method(v => v.Execute(new RestRequest())).With(NMock.Is.TypeOf(typeof(RestRequest))).WillReturn(customerResponse);
            ApiClient apiClient = new ApiClient(mockRestClient.MockObject);

            apiClient.Configuration = null;
            Identifier     identifier     = new Identifier("*****@*****.**", "Customer Reference");
            CreateCustomer updateCustomer = new CreateCustomer("create customer test", identifier, null);

            Configuration configuration = new Configuration
            {
                ApiClient      = apiClient,
                Username       = "******",
                Password       = "******",
                AccessToken    = null,
                ApiKey         = null,
                ApiKeyPrefix   = null,
                TempFolderPath = null,
                DateTimeFormat = null,
                Timeout        = 60000,
                UserAgent      = "asdasd"
            };

            instance = new CustomersApi(configuration);

            var response = instance.UpdateCustomer(customerId, updateCustomer, authorization);

            Assert.IsInstanceOf <Customer>(response, "response is Customer");
        }
        /// <summary>
        /// NavBox OnAction Handler for Create Customer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="data"></param>
        private void createCustFormNavAction(object sender, object data)
        {
            if (sender == null || data == null)
            {
                throw new ApplicationException("Create Customer form navigation action handler received invalid data");
            }

            NavBox         createCustNavBox = (NavBox)sender;
            CreateCustomer createCustForm   = (CreateCustomer)data;

            NavBox.NavAction lookupAction = createCustNavBox.Action;
            switch (lookupAction)
            {
            case NavBox.NavAction.BACKANDSUBMIT:
                GlobalDataAccessor.Instance.DesktopSession.HistorySession.Desktop();
                this.nextState = PoliceHoldReleaseFlowState.PoliceHoldReleaseInfo;
                break;

            case NavBox.NavAction.HIDEANDSHOW:
                createCustForm.Hide();
                this.nextState = PoliceHoldReleaseFlowState.UpdateAddress;
                break;

            case NavBox.NavAction.CANCEL:
                this.nextState = PoliceHoldReleaseFlowState.Cancel;
                break;

            default:
                throw new ApplicationException("" + lookupAction.ToString() + " is not a valid state for LookupCustomer");
            }

            this.executeNextState();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="data"></param>
        private void createCustomerFormNavAction(object sender, object data)
        {
            if (sender == null || data == null)
            {
                throw new ApplicationException("Create customer form navigation action handler received invalid data");
            }

            NavBox         createCustNavBox = (NavBox)sender;
            CreateCustomer createCustForm   = (CreateCustomer)data;

            NavBox.NavAction action = createCustNavBox.Action;
            if (action == NavBox.NavAction.BACKANDSUBMIT)
            {
                GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
                action = NavBox.NavAction.SUBMIT;
            }

            switch (action)
            {
            case NavBox.NavAction.SUBMIT:
                this.nextState = NewPawnLoanFlowState.ManagePawnApplication;
                break;
            }
            this.executeNextState();
        }
Example #10
0
        /// <summary>
        /// Create customer in ReePay
        /// </summary>
        /// <param name="handle">Customer id, blank for auto generate</param>
        /// <param name="email"> customer email</param>
        /// <param name="firstName">custoemer firstname</param>
        /// <param name="lastname">customer last name</param>
        /// <param name="address">customer address</param>
        /// <param name="address2">customer address2</param>
        /// <param name="city">customer city</param>
        /// <param name="postalCode">customer postal code</param>
        /// <param name="country">customer country</param>
        /// <param name="phone">customer phone</param>
        /// <param name="company">customer company</param>
        /// <param name="vat">customer vat</param>
        /// <returns>statuscode and customer data</returns>
        public ApiResponse <Customer> CreateCustomer(string handle, string email, string firstName, string lastname, string address, string address2, string city,
                                                     string postalCode, string country, string phone, string company, string vat)
        {
            var myClassname    = MethodBase.GetCurrentMethod().Name;
            var generateHandle = string.IsNullOrEmpty(handle);
            var config         = this.GetDefaultApiConfiguration();
            var api            = new CustomerApi(config);
            var newCustomer    = new CreateCustomer(email, address, address2, city, country, phone, company, vat, handle, this._reepayTestFlag, firstName, lastname, postalCode, generateHandle);

            for (var i = 0; i <= MaxNoOfRetries; i++)
            {
                try
                {
                    var apiResponse = api.CreateCustomerJsonWithHttpInfo(newCustomer);
                    return(apiResponse);
                }
                catch (ApiException apiException)
                {
                    this._log.Error($"{myClassname} {apiException.ErrorCode} {apiException.ErrorContent}");
                    return(new ApiResponse <Customer>(apiException.ErrorCode, null, null));
                }
                catch (Exception) when(i < MaxNoOfRetries)
                {
                    this._log.Debug($"{myClassname} retry attempt {i}");
                }
            }

            return(new ApiResponse <Customer>((int)HttpStatusCode.InternalServerError, null, null));
        }
Example #11
0
        public ActionResult CreateCustomer(CreateCustomer customer)
        {
            Address newAddress = new Address()
            {
                StreetAddress1 = customer.StreetAddress1, StreetAddress2 = customer.StreetAddress2, City = customer.City, State = customer.State, Country = customer.Country, Zip = customer.Zip
            };

            db.Address.Add(newAddress);
            db.SaveChanges();
            PaymentInfo newPaymentInfo = new PaymentInfo()
            {
                Last4Digits = customer.Last4Digits, AddressID = newAddress.AddressID
            };

            db.PaymentInfo.Add(newPaymentInfo);
            db.SaveChanges();
            Login newLogin = new Login()
            {
                Username = customer.Username, Password = customer.Password
            };

            db.Login.Add(newLogin);
            db.SaveChanges();
            Customer newCustomer = new Customer()
            {
                CustFirstName = customer.CustFirstName, CustLastName = customer.CustLastName, CustEmail = customer.CustEmail, AddressID = newAddress.AddressID, PaymentInfoID = newPaymentInfo.PaymentInfoID, LoginID = newLogin.LoginID
            };

            db.Customer.Add(newCustomer);
            db.SaveChanges();
            return(View("Index"));
        }
        public async Task <IActionResult> CreateCustomer(CreateCustomer command)
        {
            var customerCreated = _mapper.Map <CustomerCreated>(command);
            await _eventRepository.SaveEventAsync(customerCreated);

            return(CreatedAtAction(nameof(CustomerController.Get), new { Id = command.CustomerId }, null));
        }
Example #13
0
        public void CanGetCreateCustomer()
        {
            CreateCustomer newCustomer = new CreateCustomer
            {
                email    = "*****@*****.**",
                name     = "President",
                locale   = "en_US",
                metadata = "something"
            };
            GetCustomer createdCustomer = mollieClient.CreateCustomer(newCustomer);

            Assert.AreEqual(newCustomer.name, createdCustomer.name);
            Assert.AreEqual(newCustomer.email, createdCustomer.email);
            Assert.AreEqual(newCustomer.metadata, createdCustomer.metadata);
            Assert.AreEqual(newCustomer.locale, createdCustomer.locale);
            Assert.AreEqual("test", createdCustomer.mode);
            Assert.AreEqual("customer", createdCustomer.resource);

            Assert.IsTrue(createdCustomer.id.Length > 1);

            GetCustomer getCustomer = mollieClient.GetCustomer(createdCustomer.id);

            Assert.AreEqual(getCustomer.name, createdCustomer.name);
            Assert.AreEqual(getCustomer.name, createdCustomer.name);
            Assert.AreEqual(getCustomer.email, createdCustomer.email);
            Assert.AreEqual(getCustomer.metadata, createdCustomer.metadata);
            Assert.AreEqual(getCustomer.locale, createdCustomer.locale);
            Assert.AreEqual("test", getCustomer.mode);
            Assert.AreEqual("customer", getCustomer.resource);

            Customers customers = mollieClient.ListCustomers();

            Assert.IsTrue(customers.data.Count > 0);
        }
Example #14
0
 private static string ValidateID(CreateCustomer command, Dictionary <string, Customer> existingCustomers, Source source)
 {
     //a use case is that when customers are created through the browser an ID is assigned to them
     if (source == Source.Web)
     {
         if (!string.IsNullOrEmpty(command.id))
         {
             command.LogError(nameof(command.id), "ID can't be set");
         }
         //simplistic way to create new id
         command.id = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
     }
     else             //while when they are created through other means ID is provided to them
     {
         //often we need to proceed with processing and we can create temporary values to proceed with furter validations
         var id = (command.id ?? "TEMP-ID").ToUpperInvariant();
         if (string.IsNullOrEmpty(command.id))
         {
             command.LogError(nameof(command.id), "ID must be provided");
         }
         else if (existingCustomers.ContainsKey(id))
         {
             command.LogError(nameof(command.id), "ID already taken");
         }
         command.id = id;
     }
     return(command.id);
 }
Example #15
0
        public void TestGetCustomer()
        {
            var Customer    = new CreateCustomer(mapper, logger);
            var CustomerDet = Customer.GetCustomerByID(1);

            Assert.Pass();
        }
Example #16
0
        public IActionResult Post([FromBody] CreateCustomer command)
        {
            var id = Guid.NewGuid();

            _customerService.Create(id, command.Email);

            return(Created($"customers/{id}", null));
        }
Example #17
0
        public async Task <IActionResult> Create([FromBody] CreateCustomer command)
        {
            if (command == null)
            {
                return(this.BadRequest("command is required"));
            }

            return(this.Ok(await this.Dispatcher.Command(command: command)));
        }
        public async Task CreateCustomer(CreateCustomer command)
        {
            var customer = new Customer(command.CustomerId, command.Name);
            await Program.repository.SaveAsync(customer);

            var cpn = await Program.repository.GetCurrentCheckpointNumberAsync();

            await Program.checkpointPersister.WaitForCheckpointNumberAsync <CustomerReadModelState>(cpn);
        }
 public CreateCustomerResponse Post(CreateCustomer request)
 {
     var customer = new Customer { Name = request.Name };
     Db.Save(customer);
     return new CreateCustomerResponse
     {
         Result = customer
     };
 }
        public object Post(CreateCustomer request)
        {
            var customer = new Customer {
                Name = request.Name
            };

            Db.Save(customer);
            return(customer);
        }
Example #21
0
        public void GivenNullContractShouldThrowArgumentNullException()
        {
            var message = new CreateCustomer
            {
                CustomerId = _fixture.Create <Guid>(),
            };

            _queueService.Invoking(y => y.Enqueue <CreateCustomer>(null))
            .Should().Throw <ArgumentNullException>();
        }
Example #22
0
 static void Consume(CreateCustomer cmd, NuclearStorage storage, SimpleMessageSender sender)
 {
     var customer = new Customer(cmd.CustomerId, cmd.CustomerName);
     storage.AddEntity(customer.Id, customer);
     sender.SendOne(new CustomerCreated
         {
             CustomerId = cmd.CustomerId,
             CustomerName = cmd.CustomerName
         });
 }
        public async Task <IActionResult> AddCustomerAsync(
            [FromBody] CreateCustomer command,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var result = await Mediator.Send(command, cancellationToken).ConfigureAwait(false);

            var customer = Mapper.Map <Customer>(result);

            return(Created(Url.Link(nameof(GetCustomerByIdAsync), new { customer.Id }), ResponseFactory.CreateReponse(customer, typeof(CustomersController), ResponseStatus.Success, "1.0.0")));
        }
Example #24
0
        public async Task <ActionResult> createCustomer(CreateCustomer model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }



            CustomerCreationStatus createSuccess = new CustomerCreationStatus();

            try
            {
                var currentdate = DateTime.Now;
                var date        = DateTime.Now;
                var k           = currentdate.Year - model.DateOfBirth.Year;
                if (k <= 18)
                {
                    ViewBag.datevalidation = "Age should be greater than 18";
                    return(View(model));
                }

                var response = await _provider.Createcus(model);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var jsoncontent = await response.Content.ReadAsStringAsync();

                    createSuccess = JsonConvert.DeserializeObject <CustomerCreationStatus>(jsoncontent);
                    //return RedirectToAction("GetCustomer","Customer");
                    return(View("CreateSuccess", createSuccess));
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    ModelState.AddModelError("", "Having server issue while adding record");
                    return(View(model));
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.Conflict)
                {
                    ModelState.AddModelError("", "Username already present with ID :" + model.CustomerId);
                    return(View(model));
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    ModelState.AddModelError("", "Invalid model states");
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Exception occured due to  " + ex.Message);
            }
            return(View(model));
        }
        public void createCustomerTest()
        {
            var createCustomer = new CreateCustomer()
            {
                Email     = "*****@*****.**",
                FirstName = "Reza",
                LastName  = "Jenabi",
            };

            _createCustomerHandler.Handler(createCustomer);
        }
        public async Task <IActionResult> UpdateCustomer(int id, [FromBody] CreateCustomer command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _customerService.UpdateAsync(id, command.Name, command.Surname, command.TelephoneNumber, command.FlatNumber, command.BuildingNumber, command.Street, command.City, command.ZipCode);

            return(NoContent());
        }
Example #27
0
        static void Consume(CreateCustomer cmd, NuclearStorage storage, SimpleMessageSender sender)
        {
            var customer = new Customer(cmd.CustomerId, cmd.CustomerName);

            storage.AddEntity(customer.Id, customer);
            sender.SendOne(new CustomerCreated
            {
                CustomerId   = cmd.CustomerId,
                CustomerName = cmd.CustomerName
            });
        }
Example #28
0
        public GetCustomer CreateCustomer(CreateCustomer customer)
        {
            string jsonData = LoadWebRequest("POST", "customers", JsonConvert.SerializeObject(customer, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));
            GetCustomer getCustomer = JsonConvert.DeserializeObject <GetCustomer>(jsonData, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            return(getCustomer);
        }
        public async Task <IActionResult> Create(CreateCustomerDto dto, CancellationToken cancellationToken = default)
        {
            if (null == dto)
            {
                return(BadRequest());
            }
            var command = new CreateCustomer(Guid.NewGuid(), dto.FirstName, dto.LastName, dto.Email);
            await _mediator.Publish(command, cancellationToken);

            return(CreatedAtAction("GetCustomer", new { id = command.Id }, command));
        }
        public void Save_a_customer()
        {
            //given
            Customer           customer           = new Customer("yonay");
            CustomerRepository customerRepository = Substitute.For <CustomerRepository>();
            CreateCustomer     createCustomer     = new CreateCustomer(customerRepository);

            //when
            createCustomer.Execute(customer);
            //then
            customerRepository.Received().save(customer);
        }
        public CreateCustomerResponse Post(CreateCustomer request)
        {
            var customer = new Customer {
                Name = request.Name
            };

            Db.Save(customer);
            return(new CreateCustomerResponse
            {
                Result = customer
            });
        }
Example #32
0
        public async Task <IActionResult> CreateAsync([FromBody] CreateCustomer request, CancellationToken cancellationToken)
        {
            var address  = _mapper.Map <Domain.Address>(request.Address);
            var customer = new Customer(request.Name, address);

            _customerRepository.Add(customer);
            await _customerRepository.UnitOfWork.SaveChangesAsync(cancellationToken);

            var vm = _mapper.Map <ViewCustomer>(customer);

            return(CreatedAtAction(nameof(GetAsync), new { id = vm.Id }, vm));
        }
Example #33
0
        public object Post(CreateCustomer request)
        {
            var customer = new Customer().PopulateWith(request);

            documentSession.Store(customer);
            documentSession.SaveChanges();

            return
                new HttpResult(customer)
                    {
                        StatusCode = HttpStatusCode.Created,
                        Headers =
                            {
                                {HttpHeaders.Location, Request.AbsoluteUri.CombineWith(customer.Id)}
                            }
                    };
        }
Example #34
0
        public static CreateCustomer ToCreateCommand(this CustomerModel model)
        {
            Process(model);

            var command = new CreateCustomer
            {
                CustomerId                  = Guid.NewGuid(),
                FirstName                   = model.FirstName,
                LastName                    = model.LastName,
                MiddleName                  = model.MiddleName,
                EmailAddress                = String.IsNullOrWhiteSpace(model.EmailAddress) ? null : model.EmailAddress,
                ProfileDateUtc              = model.ProfileDateUtc.Value.ToUniversalTime(),
                PreferredLanguage           = model.PreferredLanguage,
                Gender                      = model.Gender,
                CanSendSMSToCell            = model.CanSendSMSToCell,
                Spouse                      = model.Spouse,
                ReferredBy                  = model.ReferredBy,
                Employer                    = model.Employer,
                Occupation                  = model.Occupation,
                LearningTopicsOfInterest    = new HashSet<string>(model.LearningTopicsOfInterest),
                PreferredShoppingMethods    = new HashSet<ShoppingMethod>(model.PreferredShoppingMethods),
                PreferredContactDays        = new HashSet<ContactDay>(model.PreferredContactDays),
                PreferredContactMethods     = new HashSet<ContactMethod>(model.PreferredContactMethods),
                PreferredContactFrequencies = new HashSet<ContactFrequency>(model.PreferredContactFrequencies),
                PreferredContactTimes       = new HashSet<ContactTime>(model.PreferredContactTimes),
                PhoneNumbers                = model.PhoneNumbers,
                Addresses                   = model.Addresses,
                Note                        = String.IsNullOrWhiteSpace(model.Note) ? null : model.Note
            };

            command.HyperLinks = model.SocialNetworks
                .Select
                (
                    sn =>
                    new HyperLink
                    {
                        CustomerId    = command.CustomerId, // This is lame. Need to fix in Quartet
                        HyperLinkKey  = sn.Key,
                        HyperLinkType = sn.Type,
                        Url           = new UriBuilder(sn.Url).Uri
                    }
                )
                .ToArray();

            command.EmailSubscriptions = model.Subscriptions
                .Select
                (
                    sb =>
                    new CreateCustomer.EmailSubscription
                    {
                        SubscriptionType = sb.SubscriptionType,
                        Status           = sb.SubscriptionStatus
                    }
                )
                .ToArray();

            var specialOccasions = model.ImportantDates
                .Select
                (
                    i => new SpecialOccasion
                    {
                        SpecialOccasionKey  = i.Key,
                        SpecialOccasionType = i.Type.Value,
                        Month               = i.Month,
                        Day                 = i.Day,
                        Year                = i.Year,
                        Description         = i.Description
                    }
                );

            if (model.Birthday != null && model.Birthday.Month != 0 && model.Birthday.Day != 0)
                specialOccasions = specialOccasions.Concat
                (
                    new[]
                    {
                        new SpecialOccasion
                        {
                            SpecialOccasionKey  = model.Birthday.Key,
                            SpecialOccasionType = model.Birthday.Type.Value,
                            Month               = model.Birthday.Month,
                            Day                 = model.Birthday.Day,
                            Year                = model.Birthday.Year
                        }
                    }
                );

            if (model.Anniversary != null && model.Anniversary.Month != 0 && model.Anniversary.Day != 0)
                specialOccasions = specialOccasions.Concat
                (
                    new[]
                    {
                        new SpecialOccasion
                        {
                            SpecialOccasionKey  = model.Anniversary.Key,
                            SpecialOccasionType = model.Anniversary.Type.Value,
                            Month               = model.Anniversary.Month,
                            Day                 = model.Anniversary.Day,
                            Year                = model.Anniversary.Year
                        }
                    }
                );

            command.SpecialOccasions = specialOccasions.ToArray();

            command.QuestionnaireItems = MapQuestionnaireAnswers(model.ProfileQuestionGroups);

            return command;
        }