public async Task <IActionResult> UpdateAppEntranceAsync(AppEntrance model)
        {
            try
            {
                if (model == null)
                {
                    throw new ArgumentNullException(nameof(model));
                }
                if (model.Id == Guid.Empty)
                {
                    throw new ArgumentOutOfRangeException(nameof(model.Id));
                }

                var client = Client.Default();
                var result = await _workbenchAppService.AddOrUpdateEntrancesAsync(new AddEntrancesInput
                {
                    ClientId     = client.Id,
                    AppEntrances = new List <AppEntrance> {
                        model
                    }
                });

                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #2
0
        public async Task TestUpdateAppEntranceAsync()
        {
            var model = new AppEntrance()
            {
                Id = Guid.NewGuid()
            };

            var workbenchAppService = Substitute.For <IWorkbenchAppService>();

            workbenchAppService.AddOrUpdateEntrancesAsync(Arg.Is <AddEntrancesInput>(
                                                              o => o.ClientId == Client.DefaultId && o.AppEntrances[0] == model
                                                              ))
            .Returns(Task.FromResult(true));

            var target = new WorkbenchController(
                workbenchAppService,
                Substitute.For <IClientAppService>(),
                Substitute.For <IBizSystemAppService>(),
                Substitute.For <IBadgeApiClient>(),
                Substitute.For <IMobileCodeSender>(),
                _ => Substitute.For <IUserSettingAppService>());

            target.ControllerContext = CreateMockContext();

            var result = await target.UpdateAppEntranceAsync(model);

            result.Should().BeOfType <OkObjectResult>();
            var realResult = result.As <OkObjectResult>();

            realResult.Value.Should().Be(true);
        }
Beispiel #3
0
 private AppEntranceDto CheckPlatformThenAdd(ClientPlatform clientPlatform, List <AppEntranceDto> result, AppEntrance item)
 {
     if (item.IsFolder)
     {
         var dto = _mapper.Map <AppEntranceDto>(item);
         result.Add(dto);
         return(dto);
     }
     if (item.Uris?.ContainsKey(clientPlatform) == true)
     {
         var dto = _mapper.Map <AppEntranceDto>(item);
         dto.Uri = item.Uris[clientPlatform];
         result.Add(dto);
         return(dto);
     }
     return(null);
 }