Exemple #1
0
 public void Handle(DeleteCustomer command)
 {
     ValidateCommand(command);
     Db().AddOrUpdate();
     Db().Remove(GetById(command.Id));
     Commit(new CustomerDeleted(command.Id));
 }
Exemple #2
0
        private void DeleteCustomerOnSearch(object sender, Form.SubmittedEventArgs e)
        {
            if (!int.TryParse(e.Data.Get <string>("Customer ID"), out var customerId))
            {
                e.Result = "Invalid ID";
                return;
            }

            if (_crm.Customers.All(c => c.Id != customerId))
            {
                e.Result = "No customer with that ID";
                return;
            }

            if (_fleet.IsRenting(customerId))
            {
                e.Result = "Customer still renting";
                return;
            }

            var customer = _crm.Customers.First(c => c.Id == customerId);

            var confirmForm = DeleteCustomer.GetComponent <Form>("confirm");

            confirmForm.Set("ID", customerId.ToString());
            confirmForm.Set("Given Names", customer.GivenNames);
            confirmForm.Set("Surname", customer.Surname);
            confirmForm.Set("Date of birth", customer.BirthDate.ToString("dd/MM/yyyy"));

            DeleteCustomer.ActiveComponent = "confirm";
        }
        public async Task <IActionResult> DeleteConfirmed(Guid id)
        {
            var command       = new DeleteCustomer(id: id);
            var commandResult = await this.GetDispatcher().Command(command);

            return(RedirectToAction("Index"));
        }
        public void DeleteCustomer_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.DeleteCustomer(customerDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new DeleteCustomer <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);
        }
Exemple #5
0
        public object Delete(DeleteCustomer request)
        {
            String paramDocument = request.document;

            if (paramDocument != null)
            {
                try
                {
                    Db.Delete <Customer>(p => p.document == paramDocument);
                    return(new DeleteCustomerResponse {
                        response = "Customer " + paramDocument + " deleted"
                    });
                }catch (System.Data.SqlClient.SqlException ex)
                {
                    return(new ErrorMessageResponse {
                        error = ex.Message
                    });
                }
            }
            else
            {
                return(new DeleteCustomerResponse {
                    response = "Customer document can't be null"
                });
            }
        }
Exemple #6
0
 public async override Task <CustomerDeleted> Delete(DeleteCustomer request, ServerCallContext context)
 {
     return(await Task.FromResult(new CustomerDeleted()
     {
         Id = request.Id, DateDeleted = Timestamp.FromDateTime(DateTime.UtcNow)
     }));
 }
 public CustomerViewModel()
 {
     addCustomer     = new AddCustomer(this);
     deleteCustomer  = new DeleteCustomer(this);
     updateCustomer  = new UpdateCustomer(this);
     SelectCustomer  = new CustomerEntity();
     CurrentCustomer = new CustomerEntity();
 }
Exemple #8
0
 public ActionResult DeleteCustomer(DeleteCustomer delete)
 {
     db.DeleteCustomer(delete.email);
     if (delete.email != null)
     {
         return(RedirectToAction("AdminPg"));
     }
     return(View());
 }
        public void Handle(DeleteCustomer command)
        {
            ValidateCommand(command);
            var lastCommand = GetLastCommand(command.Id);

            DeleteCustomer(command.Id);
            command.AggregateId = command.Id;
            AddEventSourcing(command, "Deleted Customer", new { });
        }
Exemple #10
0
    public void Any(DeleteCustomer request)
    {
        if (request.Id <= 0)
        {
            throw new ArgumentException("Id Required", "Id")

                  Db.DeleteById <Customer>(request.Id);
        }
    }
        public Task Handle(object Command)
        {
            return(Command switch
            {
                AddCustomer cmd => HandleCreate(cmd),
                UpdateCustomer cmd => HandleUpdate(cmd.Id, c => c.BusinessCustomerUpdate(cmd.CompanyId, cmd.FirstName, cmd.LastName, cmd.CVR, cmd.EAN, cmd.WWW, cmd.VatCode, cmd.DebitorNo, cmd.Username, cmd.Password, cmd.Text, cmd.AccountNo, cmd.LastUpdate)),
                DeleteCustomer cmd => HandleDelete(cmd.Id),

                _ => Task.CompletedTask
            });
Exemple #12
0
        public object Delete(DeleteCustomer request)
        {
            var entity = request.ConvertTo <Customer>();

            return(InTransaction(db =>
            {
                Logic.Remove(entity);
                return new CommonResponse();
            }));
        }
        public Task Handle(object Command)
        {
            return(Command switch
            {
                AddCustomer cmd => HandleCreate(cmd),
                UpdateCustomer cmd => HandleUpdate(cmd.Id, c => c.PrivateCustomerUpdate(cmd.CompanyId, cmd.FirstName, cmd.LastName, cmd.Username, cmd.Password, cmd.Text, cmd.AccountNo, cmd.LastUpdate)),
                DeleteCustomer cmd => HandleDelete(cmd.Id),

                _ => Task.CompletedTask
            });
Exemple #14
0
        public void Handle(DeleteCustomer command)
        {
            var repo = repositoryFactory();

            var customer = repo.Get(command.CustomerId);

            customer.Delete();

            repo.Save(customer, command.Id.ToString());
        }
Exemple #15
0
        private void SaveCustomerGroup()
        {
            if (!string.IsNullOrWhiteSpace(txtCustomerCodeFrom.Text) ||
                !string.IsNullOrWhiteSpace(txtCustomerCodeTo.Text))
            {
                if (!CheckRangeData())
                {
                    return;
                }
                var addTask = AddCustomerGroupAsync();
                ProgressDialog.Start(ParentForm, addTask, false, SessionKey);
            }

            var loadTask = GetChildCustomersByParentId(ParentCustomerId)
                           .ContinueWith(t => PrepareCustomerGroup(t.Result));

            ProgressDialog.Start(ParentForm, loadTask, false, SessionKey);

            var success  = false;
            var saveTask = ServiceProxyFactory.LifeTime(async factory =>
            {
                var service    = factory.Create <CustomerGroupMasterClient>();
                var saveResult = await service.SaveAsync(SessionKey,
                                                         AddCustomer.ToArray(), DeleteCustomer.ToArray());
                success = saveResult?.ProcessResult.Result ?? false;
                if (!success)
                {
                    return;
                }

                AddCustomer.Clear();
                DeleteCustomer.Clear();

                var customerGroup  = await GetChildCustomersByParentId(ParentCustomerId);
                customerGroup      = customerGroup.OrderBy((x => x.ChildCustomerCode)).ToList();
                CustomerModifyList = customerGroup;
                CustomerOriginList = customerGroup;
            });

            ProgressDialog.Start(ParentForm, saveTask, false, SessionKey);

            if (!success)
            {
                ShowWarningDialog(MsgErrSaveError);
                return;
            }

            grdCustomerModify.DataSource = new BindingSource(CustomerModifyList, null);
            grdCustomerOrigin.DataSource = new BindingSource(CustomerOriginList, null);
            txtCustomerCodeFrom.Focus();
            ClearChildCustomerInfo();
            Modified = false;

            DispStatusMessage(MsgInfSaveSuccess);
        }
        public async Task <IActionResult> DeleteCustomerByIdAsync(
            [FromRoute] int id,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var command = new DeleteCustomer {
                Id = id
            };
            await Mediator.Send(command, cancellationToken).ConfigureAwait(false);

            return(NoContent());
        }
Exemple #17
0
        public async Task <IActionResult> Delete(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(this.BadRequest("A valid id is required"));
            }

            var command = new DeleteCustomer(id: id);

            return(this.Ok(await this.Dispatcher.Command(command: command)));
        }
        public void Handle(DeleteCustomer command)
        {
            ValidateCommand(command);
            var lastEntity = Db().Include(_ => _.Address).AsNoTracking()
                             .OrderBy(_ => _.CreatedDate).FirstOrDefault(_ => _.Id == command.Id);
            var entity  = Db().Include(_ => _.Address).FirstOrDefault(_ => _.Id == command.Id);
            var address = _architectureContext.Addresses.Find(entity.Address.Id);

            var action = _architectureContext.DeleteEntity(entity);

            Commit(entity, action, lastEntity);
        }
Exemple #19
0
        public async Task <ApplicationResponse> When(DeleteCustomer command)
        {
            var customer = await _customerRepository.Get(command.Id);

            if (customer == null)
            {
                return(ApplicationResponse.Fail(StatusCode.NotFound, "Customer not found"));
            }

            await _customerRepository.Delete(customer.Id);

            return(ApplicationResponse.Success());
        }
Exemple #20
0
 public CustomerManager(CustomerResourceManager crm, Fleet fleet)
 {
     _crm   = crm;
     _fleet = fleet;
     AddCustomer.Submitted += AddCustomerOnSubmitted;
     CustomerSearch.GetComponent <Form>("initial search").Submitted += CustomerSearchOnSearch;
     CustomerSearch.GetComponent <Form>("customer list").Submitted  += CustomerSearchOnSearch;
     ModifyCustomer.GetComponent <Form>("search").Submitted         += ModifyCustomerOnSearch;
     ModifyCustomer.GetComponent <Form>("modify").Submitted         += ModifyCustomerOnSubmitted;
     DeleteCustomer.GetComponent <Form>("select").Submitted         += DeleteCustomerOnSearch;
     DeleteCustomer.GetComponent <Form>("confirm").Submitted        += DeleteCustomerOnSubmitted;
     CustomerReport.PreRender += CustomerReportOnFocused;
 }
Exemple #21
0
        public IHttpActionResult Delete(DeleteCustomer customer)
        {
            var customerToDelete = _db.Customers.Find(customer.Id);

            if (customerToDelete == null)
            {
                return(NotFound());
            }

            _db.Customers.Remove(customerToDelete);
            _db.SaveChanges();

            return(Ok());
        }
Exemple #22
0
 public ActionResult Delete(Customer c)
 {
     try
     {
         var request = new DeleteCustomer()
         {
             Id = c.Id
         };
         mediator.Send(request);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
        /// <summary>
        /// Choose this to enter the Delete Information menu
        /// </summary>
        public static void DeleteInformation()
        {
            var customer      = new DeleteCustomer();
            var bicycle       = new DeleteBicycle();
            var bookingDetail = new DeleteBooking_detail();
            var bicycleBrand  = new DeleteBicycle_brand();

            Console.Clear();
            Console.WriteLine("1: Delete Customer");
            Console.WriteLine("2: Delete Bicycle");
            Console.WriteLine("3: Delete Booking_detail");
            Console.WriteLine("4: Delete Bicycle_brand");

            Console.WriteLine("");

            var userChoice = Console.ReadLine();

            switch (userChoice)
            {
            case "1":
                customer.DeleteExistingCustomer();
                ReturnToMainMenu();
                break;

            case "2":
                bicycle.DeleteExistingBicycle();
                ReturnToMainMenu();
                break;

            case "3":
                bookingDetail.DeleteExistingCustomer();
                ReturnToMainMenu();
                break;

            case "4":
                bicycleBrand.DeleteExistingBicycleBrand();
                ReturnToMainMenu();
                break;

            default:
                Console.Clear();
                Console.WriteLine("Input does not exist!.. Press any key except the one you pressed to get here!.. try again!.. ");
                Console.ReadKey();
                DeleteInformation();
                break;
            }
        }
        public ActionResult <DeleteCustomer> DeleteCustomer(DeleteCustomer model)
        {
            try
            {
                var oldCustomer = _repository.GetCustomerById(model.CustomerId);
                if (oldCustomer == null)
                {
                    return(NotFound("The customer with the given id could not be find"));
                }

                _repository.DeleteCustomer(oldCustomer);
                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogInformation($"Failed to delete the customer:{ex}");
            }
            return(BadRequest("Failed to delte the customer"));
        }
Exemple #25
0
        public static async Task MainAsync(string[] args)
        {
            var dispatcher = ServiceProvider.GetService <IDispatcher>();

            // Command - Exception
            var createFaultedCustomerCommand = new CreateCustomer();
            var faultedResult = await dispatcher.Command(createFaultedCustomerCommand);

            // Command Create
            var createCustomerCommand = new CreateCustomer();

            createCustomerCommand.FirstName = "Louis";
            createCustomerCommand.LastName  = "Lewis";
            createCustomerCommand.UserName  = "******";

            var createResult = await dispatcher.Command(createCustomerCommand);

            var createdCustomerId = Guid.Parse(((CommandResult)createResult).RecordId);

            // Query Paged
            var queryPage        = new QueryPage();
            var queryPagedResult = await dispatcher.Query <QueryPage, GenericResultsList <CustomerLite> >(queryPage);

            // Query Single Lite
            var getCustomerQuery = new GetCustomer(id: createdCustomerId);
            var customerLite     = await dispatcher.Query <GetCustomer, CustomerLite>(getCustomerQuery);

            // Query Single Detail
            var customerDetail = await dispatcher.Query <GetCustomer, CustomerDetail>(getCustomerQuery);

            // Command Delete
            var deleteCommand = new DeleteCustomer(id: createdCustomerId);
            var deleteResult  = await dispatcher.Command(deleteCommand);

            // Message
            var exception        = new NotImplementedException("Lets throw an exception");
            var exceptionMessage = new ExceptionMessage {
                Exception = exception
            };
            await dispatcher.Message(exceptionMessage);
        }
Exemple #26
0
        /// <summary>
        ///  債権代表者マスター 登録前に AddCusotmer, DeleteCustomer を設定する処理
        /// </summary>
        /// <param name="customerGroupDB"></param>
        private void PrepareCustomerGroup(List <CustomerGroup> customerGroupDB)
        {
            if (CustomerModifyList.Any())
            {
                AddCustomer.Clear();
                DeleteCustomer.Clear();

                foreach (var item in CustomerModifyList
                         .Where(x => !customerGroupDB.Any(y => y.ChildCustomerCode == x.ChildCustomerCode)))
                {
                    item.ParentCustomerId = ParentCustomerId;
                    item.CreateBy         = Login.UserId;
                    item.UpdateBy         = Login.UserId;
                    AddCustomer.Add(item);
                }
            }

            foreach (var item in customerGroupDB
                     .Where(x => !CustomerModifyList.Any(y => y.ChildCustomerCode == x.ChildCustomerCode)))
            {
                DeleteCustomer.Add(item);
            }
        }
 public void Delete(DeleteCustomer request)
 {
     Db.DeleteById <Customer>(request.Id);
 }
 public void Delete(DeleteCustomer request)
 {
     Db.DeleteById<Customer>(request.Id);
 }
Exemple #29
0
 public object Delete(DeleteCustomer request)
 {
     throw new NotImplementedException();
 }
Exemple #30
0
 public void GivenThereIsNoCustomerWithId(int customerId)
 {
     _actor.AttemptsTo(
         DeleteCustomer.WithId(customerId));
 }
Exemple #31
0
 public ActionResult DeleteCustomer(DeleteCustomer command)
 {
     mediator.Send(command);
     return(Ok());
 }