Example #1
0
 private void DeletePersonButton_Click(object sender, EventArgs e)
 {
     if (DeletePerson != null)
     {
         DeletePerson.Invoke();
     }
 }
        private DeletePerson.Response DeletePersonHandler(DeletePerson command)
        {
            ITracer tracer = platform.Tracer;

            tracer.Write("Siemens-SimaticIT-Trace-Custom", Category.Informational, "Delete Person Start...");
            try
            {
                var entity = platform.GetEntity <IPerson>(command.Id);
                if (entity == null)
                {
                    return(new DeletePerson.Response {
                        Error = new ExecutionError(-1010, "删除的对象不存在")
                    });
                }
                platform.Delete(entity);
                tracer.Write("Siemens-SimaticIT-Trace-Custom", Category.Informational, "Delete Person End...");
                return(new DeletePerson.Response {
                });
            }
            catch (Exception ex)
            {
                return(new DeletePerson.Response {
                    Error = new ExecutionError(-1010, string.Format("删除发生异常,异常信息是:{0}", ex.Message))
                });
            }
        }
        public DeletePersonViewModel(
            Messenger messenger,
            GetPeople getPeople,
            DeletePerson deletePerson)
        {
            _messenger    = messenger;
            _deletePerson = deletePerson;
            People        = new ObservableCollection <Person>(getPeople.Execute());

            DeletePersonCommand = new RelayCommand(OnDeletePersonCommand, CanExecuteDeletePersonCommand);
        }
Example #4
0
        //Deletes
        public async Task <Unit> Handle(DeletePerson request, CancellationToken cancellationToken)
        {
            var person = await ctx.Persons.SingleOrDefaultAsync(v => v.Id == request.Id);

            if (person == null)
            {
                throw new Exception("Record not found");
            }

            ctx.Persons.Remove(person);
            await ctx.SaveChangesAsync();

            return(Unit.Value);
        }
Example #5
0
        public async Task <Unit> Handle(DeletePerson request, CancellationToken cancellationToken)
        {
            var person = await ctx.Persons.SingleOrDefaultAsync(v => v.Id == request.Id);

            if (person == null)
            {
                throw new Exception("Record does not exist");
            }

            ctx.Persons.Remove(person);
            await ctx.SaveChangesAsync();

            // await _bus.Publish<Message>(new { Value = person.Id.ToString() });

            return(Unit.Value);
        }
Example #6
0
 public async Task <IActionResult> Delete(DeletePerson command)
 => await SendAsync(command.Bind(c => c.Id, UserId),
                    resourceId : command.Id, resource : "people");
Example #7
0
 public Task Execute(DeletePerson c) => this.personRepository.Execute(
     c.PersonId,
     person => person.DeletePerson(c.PersonId));
        public async Task <IActionResult> Delete(DeletePerson request)
        {
            await mediator.Send(request);

            return(Ok());
        }
Example #9
0
        private void DeleteCustomer_OnClick(object sender, RoutedEventArgs e)
        {
            var deleteCustomerForm = new DeletePerson(new Customer());

            deleteCustomerForm.Show();
        }
Example #10
0
        private void DeleteEmployee_OnClick(object sender, RoutedEventArgs e)
        {
            var deleteEmployeeForm = new DeletePerson(new Employee());

            deleteEmployeeForm.Show();
        }
 public async Task<ActionResult> Delete(DeletePerson deletePerson)
 {
     await _mediator.SendAsync(deletePerson);
     return RedirectToAction("Index");
 } 
Example #12
0
        // Delete endpoint to remove a person from the database
        public object Delete(DeletePerson request)
        {
            var delete = Db.DeleteById <Person>(request.id);

            return(delete);
        }
Example #13
0
 public PersonController(SavePerson savePerson, DeletePerson deletePerson, IPersonRepository repository)
 {
     _savePerson   = savePerson;
     _deletePerson = deletePerson;
     _repository   = repository;
 }
Example #14
0
 public void DeleteDeelnemer(DeletePerson deelnemer)
 {
     _sender.PublishCommand(deelnemer);
 }