Example #1
0
        public async Task <IActionResult> RegisterAsync([FromBody] RegisterOwner command)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // insert owner
                    Owner owner = Mapper.Map <Owner>(command);
                    _dbContext.Owners.Add(owner);
                    await _dbContext.SaveChangesAsync();

                    // send event
                    var e = Mapper.Map <OwnerRegistered>(command);
                    await _messagePublisher.PublishMessageAsync(e.MessageType, e, "");

                    //return result
                    return(CreatedAtRoute("GetOwnerById", new { ownerID = owner.OwnerId }, owner));
                }
                return(BadRequest());
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Example #2
0
 public async Task <IActionResult> Register([FromForm] VehicleOwnerManagementNewViewModel inputModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             return(await _resiliencyHelper.ExecuteResilient(async() =>
             {
                 RegisterOwner cmd = new RegisterOwner(new Guid(),
                                                       inputModel.Owner.OwnerId,
                                                       inputModel.Owner.RazonSocial,
                                                       inputModel.Owner.CIF,
                                                       inputModel.Owner.Direccion,
                                                       inputModel.Owner.Contacto,
                                                       inputModel.Owner.Telefono);
                 await _vehicleManagementAPI.RegisterOwner(cmd);
                 return RedirectToAction("Index");
             }, View("Offline", new VehicleOwnerManagementOfflineViewModel())));
         }
         else
         {
             return(View("New", inputModel));
         }
     }
     catch (Exception ex)
     {
         return(View("Offline", new VehicleOwnerManagementOfflineViewModel()));
     }
 }
Example #3
0
        private async Task RegisterOwner()
        {
            RegisterOwner registerOwnerWindow = new RegisterOwner();

            registerOwnerWindow.ShowDialog();

            string username            = registerOwnerWindow.GetRegisteredOwnerUsername();
            string password            = registerOwnerWindow.GetRegisteredOwnerPassword();
            bool   registrationSuccess = registerOwnerWindow.IsRegistrationSuccessfull();

            if (registrationSuccess)
            {
                await LoginRegisteredOwner(username, password);
            }
        }
Example #4
0
        public async Task <IActionResult> Register([FromForm] VehicleOwnerManagementNewViewModel inputModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    RegisterOwner cmd = Mapper.Map <RegisterOwner>(inputModel.Owner);
                    await _vehicleManagementAPI.RegisterOwner(cmd);

                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    return(View("Offline", new VehicleOwnerManagementOfflineViewModel(ex.Message)));
                }
            }
            else
            {
                return(View("New", inputModel));
            }
        }
Example #5
0
 public async Task RegisterOwner(RegisterOwner command)
 {
     await _client.RegisterOwner(command);
 }
Example #6
0
 public async Task UpdateOwner(RegisterOwner command)
 {
     await _client.UpdateOwner(command);
 }