Пример #1
0
        public async Task Should_Create_User_Concurrent_Test()
        {
            await _commandService.SendAsync(new CreatePerson(11111111111)
            {
                Age    = ObjectId.GenerateNewStringId(),
                Name   = ObjectId.GenerateNewStringId(),
                Sex    = ObjectId.GenerateNewStringId(),
                Remark = ObjectId.GenerateNewStringId()
            });

            Parallel.For(0, 100000, async(i) =>
            {
                var personCommand = new CreatePerson(i)
                {
                    Age    = ObjectId.GenerateNewStringId(),
                    Name   = ObjectId.GenerateNewStringId(),
                    Sex    = ObjectId.GenerateNewStringId(),
                    Remark = ObjectId.GenerateNewStringId()
                };

                await _commandService.SendAsync(personCommand);
            });

            Thread.Sleep(20000);

            var persons = _personRepository.GetAll();
        }
Пример #2
0
        public Person CreatePerson(CreatePerson command)
        {
            if (string.IsNullOrWhiteSpace(command.Name))
            {
                throw new ValidationException($"Le champs {nameof(command.Name)} ne peut être vide");
            }

            if (string.IsNullOrWhiteSpace(command.Firstname))
            {
                throw new ValidationException($"Le champs {nameof(command.Firstname)} ne peut être vide");
            }

            if (command.PhoneNumber.Length > 11)
            {
                throw new ValidationException($"Le champs {command.PhoneNumber} ne peut être constitué que de 11 caractères maximum");
            }

            if (command.PhoneNumber.Any(char.IsLetter))
            {
                throw new ValidationException($"Le champs {command.PhoneNumber} ne peut contenir que des chiffres");
            }

            var person = new Person()
            {
                PhoneNumber = command.PhoneNumber,
                Name        = command.Name,
                Firstname   = command.Firstname,
            };

            return(person);
        }
Пример #3
0
        private TestTransaction.Response TestTransactionHandler(TestTransaction command)
        {
            try
            {
                var command1 = new CreatePerson
                {
                    Age       = 11,
                    Birthday  = DateTimeOffset.Now,
                    FirstName = "Hengdeyang",
                    IsActive  = true,
                    LastName  = "Oliv",
                    Sex       = 0
                };

                var command2 = new CreateTeam
                {
                };


                platform.CallCommand <CreatePerson, CreatePerson.Response>(command1);
                platform.CallCommand <CreateTeam, CreateTeam.Response>(command2);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private void CreateButton_Click(object sender, EventArgs e)
 {
     if (CreatePerson != null)
     {
         CreatePerson.Invoke();
     }
 }
        public ActionResult Create(Person person)
        {
            CreatePerson command = new CreatePerson(Guid.NewGuid(), person.Name, person.Street, person.StreetNumber);

            bus.Send(command);
            return(this.RedirectToAction("Index"));
        }
Пример #6
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            CreatePerson newPerson    = new CreatePerson(this);
            var          dialogResult = newPerson.ShowDialog();

            dbListBox.DataSource = dbc.Select();
        }
Пример #7
0
		static void Main(string[] args)
		{
            var kernel = new StandardKernel();
            var container = new Container(kernel);

            Configure.With(container)
                .Commands
                    .UsingJson("JsonDB")
                .Events
                    .UsingJson("JsonDB")
                .Initialize();

            var commandCoordinator = ServiceLocator.Current.GetInstance<ICommandCoordinator>();

			var command = new CreatePerson { Id = Guid.NewGuid(), FirstName = "First", LastName = "Person" };
			var result = commandCoordinator.Handle(command);
			if( !result.Success )
			{
				Console.WriteLine("Handling of command failed");
				Console.WriteLine("Exception : {0}\nStack Trace : {1}", result.Exception.Message, result.Exception.StackTrace);
			}

			var queries = container.Get<IPersonView>();
			var persons = queries.GetAll();
			foreach (var person in persons)
			{
				Console.WriteLine("Person ({0}) - {1} {2}", person.Id, person.FirstName, person.LastName);
			}
		}
        private CreatePerson.Response CreatePersonHandler(CreatePerson command)
        {
            ITracer tracer = platform.Tracer;

            try
            {
                var teams = platform.Query <IPerson>().FirstOrDefault(p => p.Name == command.Name);
                if (teams != null)
                {
                    return(new CreatePerson.Response {
                        Error = new ExecutionError(-1010, "不允许重复创建")
                    });
                }

                var entity = platform.Create <IPerson>();
                entity.Name = command.Name;
                platform.Submit(entity);

                return(new CreatePerson.Response {
                    Id = entity.Id
                });
            }
            catch (Exception ex)
            {
                tracer.Write("Siemens-SimaticIT-Trace-BusinessLogic", Category.Error, ex.Message);
                return(new CreatePerson.Response {
                    Error = new ExecutionError(-1010, ex.Message)
                });
            }
        }
Пример #9
0
        public IActionResult NewPerson()
        {
            var model = new CreatePerson {
            };

            return(View("NewPerson", model));
        }
Пример #10
0
        public ActionResult Create()
        {
            CreatePerson viewModel = new CreatePerson {
                Person = new Person(), States = GetStates()
            };

            return(View(viewModel));
        }
 public static Person ToPerson(this CreatePerson dto)
 {
     return(new Person
     {
         Name = dto.Name,
         Email = dto.Email
     });
 }
Пример #12
0
 public string GetLastUpdatedBy()
 {
     if (UpdatePersonID.HasValue)
     {
         return(UpdatePerson.GetFullNameFirstLast());
     }
     return(CreatePerson.GetFullNameFirstLast());
 }
 public IActionResult Post([FromBody] CreatePerson createPerson)
 {
     if (createPerson == null)
     {
         return(Json(new { Message = "Server kon verzonden bericht niet correct lezen" }));
     }
     _service.CreateDeelnemer(createPerson);
     return(Ok());
 }
Пример #14
0
        public IHttpActionResult Create(CreatePerson command)
        {
            // Crée une nouvelle personne
            var servicePerson = new PersonsService();

            var newPerson = servicePerson.CreatePerson(command);

            return(Ok(newPerson));
        }
Пример #15
0
        private ActionResult <CreatePersonResponseDto> _CreatePerson(CreatePerson createPerson)
        {
            var createPersonDto = new CreatePersonDto()
            {
                DOME_createPerson = new CreatePersonInnerDto()
                {
                    personCivilityId          = (int?)createPerson.PersonCivility ?? -1,
                    personCivilityIdSpecified = createPerson.PersonCivility.HasValue,

                    personBirthDate          = (DateTime?)createPerson.PersonBirthDate ?? DateTime.MinValue.Date,
                    personBirthDateSpecified = createPerson.PersonBirthDate.HasValue,

                    personAddressComp1      = createPerson.PersonAddressComp1,
                    personAddressComp2      = createPerson.PersonAddressComp2,
                    personBirthName         = createPerson.PersonBirthName,
                    personCedex             = createPerson.PersonCedex,
                    personCityName          = createPerson.PersonCityName,
                    personCityZipCode       = createPerson.PersonCityZipCode,
                    personComment           = createPerson.PersonComment,
                    personEmail1            = createPerson.PersonEmail1,
                    personEmail2            = createPerson.PersonEmail2,
                    personFirstName         = createPerson.PersonFirstName,
                    personINSA              = createPerson.PersonInsa,
                    personINSC              = createPerson.PersonInsc,
                    personJob               = createPerson.PersonJob,
                    personLastName          = createPerson.PersonLastName,
                    personLieuDit           = createPerson.PersonLieuDit,
                    personMobilePhoneNumber = createPerson.PersonMobilePhoneNumber,
                    personNIR               = createPerson.PersonNir,
                    personPhoneNumber       = createPerson.PersonPhoneNumber,
                    personPostBox           = createPerson.PersonPostBox,
                    personRoadName          = createPerson.PersonRoadName,
                    personRoadNumber        = createPerson.PersonRoadNumber,
                    personRoadType          = createPerson.PersonRoadType,
                    personRPPS              = createPerson.PersonRpps,
                    specialCriteria         = createPerson.SpecialCriteria,
                },
                DOME_header = new domeHeaderDto()
                {
                    langue = "fr",
                    deviceTypeSpecified = true,
                    deviceType          = (int)DeviceType,
                    dateSpecified       = true,
                    date    = AuthentificationHelper.date,
                    version = AuthentificationHelper.version,
                }
            };

            var createPersonDomeResult = DomeCallSoap.CreatePerson(createPersonDto);

            if (createPersonDomeResult.statusId == 0)
            {
                return(new ActionResult <CreatePersonResponseDto>(true, createPersonDomeResult));
            }
            return(new ActionResult <CreatePersonResponseDto>(false, createPersonDomeResult, new Message(MessageType.Error, createPersonDomeResult.statusErrorMessage)));
        }
Пример #16
0
 public IHttpActionResult Create(CreatePerson command)
 {
     try {
         _repository.CreatePerson(command);
     }
     catch (Exception ex) {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
     return(Ok());
 }
Пример #17
0
        public Person Add(CreatePerson createPerson)
        {
            if (createPerson.CityId == 0)
            {
                createPerson.CityId = null;
            }
            Person createdPerson = _personRepo.Create(createPerson);

            return(createdPerson);
        }
Пример #18
0
        public static void Main(string[] args)
        {
            var container = BuildContainer();

            var mediator = container.Resolve<IMediator>();

            var command = new CreatePerson("Kristian", "Hellang");

            var person = mediator.Handle(command, CancellationToken.None).Result;
        }
Пример #19
0
        public ActionResult <Person> Create([FromBody] CreatePerson person)
        {
            // ModelStae.isValid
            if (ModelState.IsValid)
            {
                return(_peopleService.Add(person));
            }

            return(BadRequest(person));
        }
Пример #20
0
        public CreatePerson PersonToCreatePerson(Person person)
        {
            CreatePerson createPerson = new CreatePerson(_cityService);

            createPerson.Name     = person.Name;
            createPerson.InCityId = person.InCityId;
            createPerson.Phone    = person.Phone;

            return(createPerson);
        }
Пример #21
0
        public int CreatePerson(CreatePerson cmd)
        {
            _logger.LogInformation("Creating person");

            var person = cmd.ToPerson();

            _personContext.Add(person);
            _personContext.SaveChanges();
            return(person.Id);
        }
Пример #22
0
        public CreatePerson PersonToCreatePerson(Person person)
        {
            CreatePerson createPerson = new CreatePerson();

            createPerson.FirstName       = person.FirstName;
            createPerson.LastName        = person.LastName;
            createPerson.CurrentCity     = person.CurrentCity;
            createPerson.CellphoneNumber = person.CellphoneNumber;

            return(createPerson);
        }
Пример #23
0
 public Task Execute(CreatePerson c) => this.personRepository.CreateAndExecute(
     c.PersonId,
     person => person.Create(
         c.PersonId,
         c.NfcId,
         c.Lastname,
         c.Firstname,
         c.DisplayName,
         new ContactInformation(c.Phone, c.Email, c.Twitter),
         c.Info,
         c.Timestamp));
Пример #24
0
        public IActionResult Post([FromBody] CreatePerson command)
        {
            // Tworzenie Akka message

            var person    = _mapper.Map <Person>(command);
            var createMsg = CreatePersonMsg.Instane(person);

            /* 1. brak kontroli typów dla messaga. Mozemy przez pomyłkę stworzyć i wysłać nie ten Msg*/
            /* 2. Tell - nie wiemy czy zapis sie powiodl - test with name: errorName*/
            _personsManagerActor.Tell(createMsg);
            return(Accepted());
        }
Пример #25
0
 private void PrepareCommand(IMassTransitCommand command)
 {
     switch (command.Command.ToLower())
     {
     case "createperson":
     {
         var person = new CreatePerson(command.ReplyToQueue, command.Commander, command.CommandId, command.Payload);
         Self.Tell(person);
     }
     break;
     }
 }
Пример #26
0
        public Person Add(CreatePerson createPerson)        // Service will do the conversion
        {
            Person person = new Person();

            person.Name     = createPerson.Name;
            person.InCityId = createPerson.InCityId;
            person.Phone    = createPerson.Phone;

            person = _peopleRepo.Create(person);

            return(person);                                  // The person is returned with the right Id
        }
Пример #27
0
        public async Task <CreatePersonResponse> CreatePerson(string FaceId, CreatePerson createPerson)
        {
            cogniativeServiceClient.AddDefaultHeader("Ocp-Apim-Subscription-Key", Settings.CogniativeServiceKey);

            var request = new RestRequest("persongroups/{persongroupid}/persons");

            request.AddJsonBody(createPerson);
            request.AddUrlSegment("persongroupid", Settings.CogniativeServicePersonGroupId);

            var response = await cogniativeServiceClient.PostAsync <CreatePersonResponse>(request);

            return(response);
        }
Пример #28
0
        public Person Add(CreatePerson createPerson)
        {
            Person person = new Person();

            person.FirstName       = createPerson.FirstName;
            person.LastName        = createPerson.LastName;
            person.CurrentCity     = createPerson.CurrentCity;
            person.CellphoneNumber = createPerson.CellphoneNumber;

            person = _peopleRepo.Create(person);

            return(person);
        }
Пример #29
0
        public void AddPersonPublishesPersonCreatedCommand()
        {
            var sender     = Substitute.For <ISender>();
            var controller = new PeopleController(sender);

            var command = new CreatePerson {
                FirstName = "first", LastName = "last"
            };

            controller.Create(command);

            sender.Received(1).PublishCommand(command);
        }
Пример #30
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
            [RequestBodyType(typeof(RegisterRequest), "Register Request")] HttpRequest req, ILogger log)
        {
            try
            {
                var jsonString = await req.ReadAsStringAsync();

                var registerRequest = JsonConvert.DeserializeObject <RegisterRequest>(jsonString);

                if (string.IsNullOrEmpty(registerRequest.DataUri))
                {
                    log.LogError("Picture not recvieved to backend for e-mail : {0}", registerRequest.Email);
                    return(BadRequest(ErrorMessages.ImageNotFound));
                }

                var createPerson = new CreatePerson()
                {
                    name     = registerRequest.Email,
                    userData = registerRequest.FullName
                };

                var image = _formatter.DataUriToByteArray(registerRequest.DataUri);

                var detectedFace = await _cogniativeService.DetectFaceRequest(image);

                if (detectedFace.Count == 0)
                {
                    log.LogError("Face not found in the image: {0}", registerRequest.DataUri);
                    return(NotFound(ErrorMessages.FaceNotFound));
                }
                else if (detectedFace.Count > 1)
                {
                    log.LogError("Too many faces detected in image: {0}", registerRequest.DataUri);
                    return(BadRequest(ErrorMessages.TooManyFacesDetected));
                }

                var person = await _cogniativeService.CreatePerson(detectedFace[0].faceId, createPerson);

                await _cogniativeService.AddFace(person.personId, image);

                await _cogniativeService.TrainPersonGroup();

                return(Ok(createPerson));
            }
            catch (Exception ex)
            {
                log.LogError(ex, $"Technical Error: {ex.Message}");
                return(BadRequest(string.Format("Technical Error, unable to register: {0}", ex.InnerException.Message)));
            }
        }
Пример #31
0
        public void CreateCounters()
        {
            var countersToCreate = new CounterCreationDataCollection();

            GetPeople.RegisterCountersForCreation(countersToCreate);
            CreatePerson.RegisterCountersForCreation(countersToCreate);
            PersonRepositoryError.RegisterCountersForCreation(countersToCreate);

            PerformanceCounterCategory.Create(
                CategoryName,
                CategoryName,
                PerformanceCounterCategoryType.SingleInstance,
                countersToCreate);
        }
Пример #32
0
        public void should_post_a_person_to_api()
        {
            var jack   = Actor.Named("Jack").WhoCan(CallAnApi.At(_fixture.Host.BaseUrl));
            var person = new CreatePerson {
                Firstname = "Sarah", Lastname = "Ohara"
            };

            jack.AttemptsTo(Post.DataAsJson(person).To("api/People"));
            var resourceLocation = jack.AsksFor(LastResponse.Header(HttpHeaders.Location));

            jack.AttemptsTo(Get.ResourceAt(resourceLocation));

            jack.Should(See.That(LastResponse.Content <Person>()))
            .Considering().All.Properties.HasFieldsWithSameValues(person);
        }
Пример #33
0
        protected Person Seed(int? establishmentId, CreatePerson command)
        {
            // make sure entity does not already exist
            var person = _queryProcessor.Execute(new PersonByEmail(command.EmailAddresses.First().Value));
            if (person != null) return person;

            if (string.IsNullOrWhiteSpace(command.DisplayName))
            {
                command.DisplayName = string.Format("{0} {1}", command.FirstName, command.LastName);
            }

            _createPerson.Handle(command);
            _unitOfWork.SaveChanges();
            person = command.CreatedPerson;

            if (establishmentId.HasValue)
            {
                _createAffiliation.Handle(new CreateAffiliation
                {
                    EstablishmentId = establishmentId.Value,
                    PersonId = person.RevisionId,
                    IsPrimary = true,
                    IsClaimingEmployee = true,
                    IsClaimingStudent = false,
                });
                _unitOfWork.SaveChanges();
            }
            else
            {
                throw new NotSupportedException("Why is the person not affiliated with an employer?");
            }

            return person;
        }
 public async Task<ActionResult> Create(CreatePerson createPerson)
 {
     var person = await _mediator.SendAsync(createPerson);
     return RedirectToAction("Details", new {Id = person.Id});
 }