public static bool InsertOrders(List <Porder> orders)
        {
            bool inserted = false;
            int  count    = 0;

            foreach (Porder order in orders)
            {
                count = new Crud().AddOrder(order);

                if (count != 0)
                {
                    inserted = true;
                }
            }

            List <Customer> customers = CustomerHandler.GetCustomers();

            foreach (Customer customer in customers)
            {
                if (customer.PUserId != orders[0].PUserId)
                {
                    inserted = CustomerHandler.AddCustomer(orders[0].PUserId);
                }
            }

            return(inserted);
        }
示例#2
0
        public async Task GiveGetCustomerQueryWhenHandleThenCustomerDetails()
        {
            // Arrange
            var expect = new Customer
            {
                Age        = 35,
                City       = "Chennai",
                Country    = "India",
                Name       = "Mark",
                State      = "Tamil Nadu",
                CustomerId = Guid.NewGuid(),
            };
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new CustomerProfile());
            });
            var mapper = mockMapper.CreateMapper();
            var redis  = A.Fake <ICustomerRedisContext>();

            A.CallTo(() => redis.GetCustomer(expect.CustomerId)).Returns(expect);
            var handle = new CustomerHandler(mapper, redis);

            // Act
            var response = await handle.Handle(new GetCustomerRequest(expect.CustomerId), A.Dummy <CancellationToken>()).ConfigureAwait(false);

            // Assert
            Assert.Equal(35, response.Age);
        }
示例#3
0
        public async Task <IActionResult> DeleteCustomer([FromBody] CustomerDataModel customerDataModel)
        {
            try
            {
                if (customerDataModel != null)
                {
                    //delete Customer Listing Favorites Mapping
                    //delete Customer Listing Recommendations
                    //delete Customer MediaFileMapping
                    //delete Customer Store Favorites Mapping
                    //delete Measurements Profile

                    var customerDeleted = await CustomerHandler.DeleteCustomer(customerDataModel.Customer);

                    if (customerDeleted == false)
                    {
                        return(StatusCode(505, "An unexpected error has ocurred, unable to delete Customer"));
                    }
                    Logger.LogWarning("Customer deleted");
                    return(Ok(customerDeleted));
                }
                return(StatusCode(404));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                return(StatusCode(505, ex.Message));
            }
        }
示例#4
0
        public override void DoDelete()
        {
            if (_current == null)
            {
                return;
            }


            try
            {
                if (XtraMessageBox.Show("Il contatto sarà eliminato solamente se nel sistema non ci sono altri riferimenti al contatto. Sicuro di voler procedere? ", "Elimina contatto", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Nested_CheckSecurityForDeletion();

                    CustomerHandler h = new CustomerHandler();
                    h.Delete(_current);

                    _mainForm.NavigatorUtility.NavigateToPrevious();
                }
            }
            catch (AccessDeniedException)
            {
                XtraMessageBox.Show("Impossibile accedere alla funzionalità richiesta. Accesso negato", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                ErrorHandler.Show(ex);
            }
        }
        public async Task <ActionResult <GenericCommandResult> > removeAddress(
            [FromBody] RemoveCustomerAddresCommand command,
            [FromServices] CustomerHandler handler
            )
        {
            var role       = User.Claims.FirstOrDefault(x => x.Type.Equals(ClaimTypes.Role))?.Value;
            var customerId = int.Parse(User.Claims.FirstOrDefault(x => x.Type.Equals(ClaimTypes.NameIdentifier))?.Value);

            if (command.CustomerId == 0)
            {
                command.CustomerId = customerId;
            }

            if (customerId != command.CustomerId && role != "manager")
            {
                return(Unauthorized());
            }

            var result = (GenericCommandResult)handler.Handle(command);

            if (result.Data == null)
            {
                return(NotFound(result));
            }

            return(Ok(result));
        }
        public async Task <ActionResult <GenericCommandResult> > AddCreditCard(
            [FromBody] CreateCustomerCreditCardCommand command,
            [FromServices] CustomerHandler handler
            )
        {
            var role       = User.Claims.FirstOrDefault(x => x.Type.Equals(ClaimTypes.Role))?.Value;
            var customerId = int.Parse(User.Claims.FirstOrDefault(x => x.Type.Equals(ClaimTypes.NameIdentifier))?.Value);

            if (command.CustomerId == 0)
            {
                command.CustomerId = customerId;
            }

            if (customerId != command.CustomerId && role != "manager")
            {
                return(Unauthorized());
            }

            var validationResult = command.Validate();

            if (!validationResult.Success)
            {
                return(BadRequest(validationResult));
            }

            var result = (GenericCommandResult)handler.Handle(command);

            if (result.Data == null)
            {
                return(NotFound(result));
            }

            return(Ok(result));
        }
        public async Task <ActionResult <GenericCommandResult> > UpdatePersonData(
            [FromBody] UpdateCustomerPersonDataCommand command,
            [FromServices] CustomerHandler handler,
            [FromServices] ICustomerRepository repository
            )
        {
            var email = User.Claims.FirstOrDefault(x => x.Type.Equals(ClaimTypes.Email))?.Value;
            var role  = User.Claims.FirstOrDefault(x => x.Type.Equals(ClaimTypes.Role))?.Value;

            var customer = repository.GetByEmail(command.Email);

            command.MergeEntity(customer);

            if (email != command.Email && role != "manager")
            {
                return(Unauthorized());
            }

            var validationResult = command.Validate();

            if (!validationResult.Success)
            {
                return(BadRequest(validationResult));
            }

            var result = handler.Handle(command);

            return(Ok(result));
        }
        public async Task <ActionResult <GenericCommandResult> > Create(
            [FromBody] CreateCustomerCommand command,
            [FromServices] CustomerHandler handler,
            [FromServices] UserHandler userHandler
            )
        {
            var validationResult = command.Validate();

            if (!validationResult.Success)
            {
                return(BadRequest(validationResult));
            }

            var userResult = (GenericCommandResult)userHandler.Handle(new CreateUserCommand(command.Email, command.Password, "customer"));

            if (userResult.Success)
            {
                var user = (User)userResult.Data;
                command.SetUserId(user.Id);


                var result = handler.Handle(command);
                return(Ok(result));
            }

            return(BadRequest(userResult));
        }
示例#9
0
 public TestController(GetLang _getLang, ICustomerService customerService, CustomerHandler customerHandler)
 {
     getLang          = _getLang;
     langcode         = getLang.GetLanguage();
     _customerService = customerService;
     CustomerHandler  = customerHandler;
 }
示例#10
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (txtboxEmail.Text != "" && txtboxPassword.Text != "" && txtboxConfirmPassword.Text != "" && txtboxFirstName.Text != "" && txtboxSurname.Text != "" && txtboxPhoneNumber.Text != "" && txtboxAddress.Text != "" &&
         calDateOfBirth.SelectedDate != null)
     {
         if (txtboxPassword.Text == txtboxConfirmPassword.Text)
         {
             if (CustomerHandler.addCustomer(txtboxFirstName.Text, txtboxSurname.Text, txtboxEmail.Text, txtboxPassword.Text, int.Parse(dropGender.SelectedValue), calDateOfBirth.SelectedDate, txtboxPhoneNumber.Text, txtboxAddress.Text))
             {
                 HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=\"\"JavaScript\"\">alert(\"Registration successful! You will now be redirected.\")</SCRIPT>");
                 HttpContext.Current.Response.Redirect("../customer/RouteListing.aspx");
                 // Success
             }
             else
             {
                 HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=\"\"JavaScript\"\">alert(\"An error occurred during the creation of your account. Please try again.\")</SCRIPT>");
             }
         }
         else
         {
             HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=\"\"JavaScript\"\">alert(\"Password mismatch. Please enter your passwords again.\")</SCRIPT>");
             txtboxPassword.Text        = "";
             txtboxConfirmPassword.Text = "";
         }
     }
     else
     {
         HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=\"\"JavaScript\"\">alert(\"All fields must be completed.\")</SCRIPT>");
     }
 }
示例#11
0
文件: Extender.cs 项目: fcvmv/50c-API
        public void Dispose()
        {
            if (systemHandler != null)
            {
                systemHandler.Dispose();
                systemHandler = null;
            }

            if (customerHandler != null)
            {
                customerHandler.Dispose();
                customerHandler = null;
            }

            if (supplierHandler != null)
            {
                supplierHandler.Dispose();
                supplierHandler = null;
            }

            if (salesmanHandler != null)
            {
                salesmanHandler.Dispose();
                salesmanHandler = null;
            }

            if (otherContactHandler != null)
            {
                otherContactHandler.Dispose();
                otherContactHandler = null;
            }
        }
示例#12
0
        protected override void InitializeWebServer(IEtpSelfHostedWebServer webServer)
        {
            var webServerHandler = new CustomerHandler();

            InitializeRegistrar(webServer.ServerManager, webServerHandler);
            Handlers.Add(webServerHandler);
        }
示例#13
0
    // Use this for initialization
    void Start()
    {
        _instance             = this;
        noOfUnpayingCustomers = 0;
        StartCoroutine("BringCustomers");
        timerText.text = "02:00";
        int remainderVal = LevelManager.levelNo % 10;

        if (remainderVal > 6 || remainderVal == 0)
        {
            canBeAnUnPayingCustomer = true;
            if (remainderVal == 7)
            {
                maxNoOfUnpayableCustomers = 1;
            }
            else if (remainderVal == 8)
            {
                maxNoOfUnpayableCustomers = Random.Range(1, 3);
            }
            else if (remainderVal == 9)
            {
                maxNoOfUnpayableCustomers = Random.Range(1, 4);
            }
            else
            {
                maxNoOfUnpayableCustomers = Random.Range(3, 5);
            }
        }
    }
示例#14
0
 public CustomerWindow()
 {
     _customerHandler = new CustomerHandler();
     CustomerSource   = _customerHandler.GetCustomers("");
     InitializeComponent();
     RefreshButtonEnabled();
 }
 public AddItemReturnWindow()
 {
     _itemReturnHandler = new ItemReturnHandler();
     ItemsSource        = new ProductHandler().GetItems();
     CustomerSource     = new CustomerHandler().GetCustomers();
     InitializeComponent();
 }
示例#16
0
        protected override void InitializeClient(IEtpClient client)
        {
            var clientStoreHandler = new CustomerHandler();

            InitializeRegistrar(client, clientStoreHandler);
            clientStoreHandler.InitializeSession(client);
            Handlers.Add(clientStoreHandler);
        }
示例#17
0
        private void LoadGrid()
        {
            CustomerHandler h = new CustomerHandler();

            IList l = h.GetAll();

            gridControl1.DataSource = l;
        }
 public AccountsController(IAuthService authService, ILogger <AccountsController> logger, GetLang _getLang, ICustomerService customerService, CustomerHandler customerHandler)
 {
     getLang          = _getLang;
     _authService     = authService;
     langcode         = getLang.GetLanguage();
     _customerService = customerService;
     CustomerHandler  = customerHandler;
     _logger          = logger;
 }
示例#19
0
 public LoginHandler()
 {
     Ch = new CustomerHandler();
     MenuLoginVisibilty   = Visibility.Visible;
     MenuLogoutVisibility = Visibility.Collapsed;
     MenuProfileVisibilty = Visibility.Collapsed;
     MenuCreateUserGrid   = Visibility.Collapsed;
     LoginUserGrid        = Visibility.Visible;
 }
        public void ShouldNotRegisterCustomerWhenDocumentExists()
        {
            _command.Document = "22328792910";
            _command.Username = "******";
            var handler = new CustomerHandler(new MockCustomerRepository());
            var result  = handler.Handle(_command);

            Assert.AreEqual(null, result);
            Assert.AreNotEqual(true, handler.Valid);
        }
示例#21
0
 public ClaimsController(ILogger <ClaimsController> logger, IHttpContextAccessor httpContextAccessor, GetLang _getLang,
                         ClaimsHandler claimsHandler, CustomerHandler customerHandler)
 {
     _logger = logger;
     _httpContextAccessor = httpContextAccessor;
     getLang         = _getLang;
     langcode        = getLang.GetLanguage();
     _claimsHandler  = claimsHandler;
     CustomerHandler = customerHandler;
 }
        public void ShouldNotRegisterCustomerWhenUsernameExistis()
        {
            _command.Document = "46718115533";
            _command.Username = "******";
            var handler = new CustomerHandler(new MockCustomerRepository());
            var result  = handler.Handle(_command);

            Assert.AreEqual(null, result);
            Assert.AreNotEqual(true, handler.Valid);
        }
示例#23
0
        public UnitTests()
        {
            var accountHandler     = new AccountHandler();
            var customerHandler    = new CustomerHandler();
            var transactionHandler = new TransactionHandler();
            var fakeFileHandler    = new FakeFileHandler();

            _bank = new Bank(new FakeFileHandler(), customerHandler, transactionHandler, accountHandler);
            Seed();
        }
示例#24
0
 public LoginController(CustomerHandler customerHandler, ILogger <LoginController> logger, IAuthService authenticationService, ICustomerService customerService, IOptions <ApplConfig> _config, GetLang _getLang)
 {
     CustomerHandler        = customerHandler;
     _customerService       = customerService;
     _logger                = logger;
     appSettings            = _config;
     getLang                = _getLang;
     langcode               = getLang.GetLanguage();
     _authenticationService = authenticationService;
 }
示例#25
0
 public LoginHandler(Visibility menuLoginVisibility, Visibility menuLogoutVisibility, Visibility menuProfileVisibility, Visibility menuCreateUserGrid, string customerName, string customerAdress, string customerZipcode, string customerCity, string customerEmail, string customerPhone, string customerGender, DateTime customerBirthday, string customerPassword, Visibility loginUserGrid, CustomerHandler ch, Visibility profileUserGrid)
 {
     Ch = ch;
     MenuLoginVisibilty   = menuLoginVisibility;
     MenuLogoutVisibility = menuLogoutVisibility;
     MenuProfileVisibilty = menuProfileVisibility;
     MenuCreateUserGrid   = menuCreateUserGrid;
     LoginUserGrid        = loginUserGrid;
     ProfileUserGrid      = profileUserGrid;
 }
示例#26
0
        protected override void Nested_LoadDataFromDataSource()
        {
            CustomerHandler h = new CustomerHandler();

            _current = h.GetElementById(m_IdShowedObject.ToString()) as Customer;

            if (_current == null)
            {
                throw new Exception("Contatto non trovato");
            }
        }
        public async Task <IActionResult> Post()
        {
            CustomerHandler dal = new CustomerHandler();
            await dal.Save(new Customer()
            {
                Name  = "Chetan",
                Email = "*****@*****.**"
            });

            return(Ok());
        }
示例#28
0
        public async void ShouldValidFalseWhenEmailIsNotAvailable()
        {
            var customerRepository = new MockCustomerRepository();

            var customerHandler = new CustomerHandler(customerRepository);

            var createCustomerCommand = new CreateCustomerCommand("Steve", "Rogers", "61946855065", "*****@*****.**", "016999999999");

            await customerHandler.Handle(createCustomerCommand, CancellationToken.None);

            Assert.False(customerHandler.Valid);
        }
示例#29
0
        public String getCustomer(String username, String password)
        {
            String   result   = "Username and Password mismatch";
            Customer customer = new CustomerHandler().getCustomer(username, password);

            if (customer != null)
            {
                //                result = JSONHelper.convertToJSON(user);
                result = customer.convertToJSON();
            }
            return(result);
        }
示例#30
0
 public ClaimsController(IAuthService authService, ICustomerService customerService, IListFactory listFactory, ILogger <ClaimsController> logger, IHttpContextAccessor httpContextAccessor, GetLang _getLang,
                         ClaimsHandler claimsHandler, CustomerHandler customerHandler)
 {
     _authenticationService = authService;
     this._listFactory      = listFactory;
     this._customerService  = customerService;
     _logger = logger;
     _httpContextAccessor = httpContextAccessor;
     getLang         = _getLang;
     langcode        = getLang.GetLanguage();
     _claimsHandler  = claimsHandler;
     CustomerHandler = customerHandler;
 }