public IActionResult Post([FromBody] RegisterDataCollector command) { //TODO: Question: Set DataCollectorId here, in CommandHandler or make the request contain the DataCollectorId? command.DataCollectorId = Guid.NewGuid(); _dataCollectorCommandHandler.Handle(command); return(Ok()); }
public void Handle(RegisterDataCollector command) { var root = _repository.Get(command.DataCollectorId); root.RegisterDataCollector( command.FullName, command.DisplayName, command.YearOfBirth, command.Sex, command.NationalSociety, command.PreferredLanguage, command.GpsLocation, command.PhoneNumbers, DateTimeOffset.UtcNow ); }
public IActionResult Register([FromBody] Read.DataCollectors.DataCollector dataCollector) { var command = new RegisterDataCollector { DataCollectorId = Guid.NewGuid(), IsNewRegistration = true, RegisteredAt = DateTimeOffset.UtcNow, PhoneNumbers = dataCollector.PhoneNumbers.Select(pn => pn.Value), DisplayName = dataCollector.DisplayName, FullName = dataCollector.FullName, GpsLocation = dataCollector.Location, NationalSociety = dataCollector.NationalSociety, PreferredLanguage = dataCollector.PreferredLanguage, Sex = dataCollector.Sex, YearOfBirth = dataCollector.YearOfBirth }; _dataCollectorCommandHandler.Handle(command); return(Ok()); }
public IActionResult Update([FromBody] Read.DataCollectors.DataCollector dataCollector) { // TODO: Woksin (10/04/18): Hmm, I'm thinking here, maybe send the original DataCollector with command // to compare fields, and from there the AggregateRoot can decide which fields to update? @einari var command = new RegisterDataCollector { DataCollectorId = dataCollector.DataCollectorId, IsNewRegistration = false, RegisteredAt = dataCollector.RegisteredAt, PhoneNumbers = dataCollector.PhoneNumbers.Select(pn => pn.Value), DisplayName = dataCollector.DisplayName, FullName = dataCollector.FullName, GpsLocation = dataCollector.Location, NationalSociety = dataCollector.NationalSociety, PreferredLanguage = dataCollector.PreferredLanguage, Sex = dataCollector.Sex, YearOfBirth = dataCollector.YearOfBirth }; _dataCollectorCommandHandler.Handle(command); return(Ok()); }