public async Task GetGroupByIdAsyncWithCorrectDataShouldReturnCorrectResult() { MapperInitializer.InitializeMapper(); var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var cloudinary = new Mock <ICloudinaryService>(); var concertGroupsRepository = new EfRepository <ConcertGroup>(dbContext); var groupsRepository = new EfDeletableEntityRepository <Group>(dbContext); var groupGenresRepository = new EfRepository <GroupGenre>(dbContext); var usertGroupsRepository = new EfRepository <UserGroup>(dbContext); var groupService = new GroupsService(concertGroupsRepository, groupsRepository, groupGenresRepository, usertGroupsRepository, cloudinary.Object); await groupsRepository.AddAsync(new Group { Id = 1, Name = "Sabaton", ImgUrl = "url", Description = "description", }); await groupsRepository.SaveChangesAsync(); var group = await groupService.GetGroupByIdAsync <GroupTestVewModel>(1); var actual = group.Name; var expected = "Sabaton"; Assert.Equal(expected, actual); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ManageContactGroups); GroupsService groupsService = new GroupsService(); groups = groupsService.GetAll().ToList(); allGroups = groupsService.GetAll().ToList(); MainActivity.SelectedContact.Groups = groupsService.GetAllByContactID(MainActivity.SelectedContact.ID).ToList(); ListView groupsListView = FindViewById <ListView>(Resource.Id.listViewGroups); Button btnUpdate = FindViewById <Button>(Resource.Id.btnUpdateGroups); GroupsViewAdapter adapter = new GroupsViewAdapter(this, Resource.Layout.ViewModel, allGroups); groupsListView.Adapter = adapter; groupsListView.ChoiceMode = ChoiceMode.Multiple; //populates all user contact and selects the ones that the contact participates groupsListView.ChildViewAdded += GroupsListView_ChildViewAdded; //selects and deselects groups /*ONCLICK BUG */ groupsListView.ItemClick += GroupsListView_ItemClick; //refreshes the groups of the current contact btnUpdate.Click += BtnUpdate_Click; }
public void LoadGroupData(bool reload = true, bool suppressLoading = true) { if (this._isLoading) { return; } this._isLoading = true; base.SetInProgress(true, reload ? CommonResources.Refreshing : CommonResources.Loading); Action <BackendResult <GroupData, ResultCode> > _9__1 = null; Execute.ExecuteOnUIThread(delegate { GroupsService arg_2F_0 = GroupsService.Current; long arg_2F_1 = this._gid; Action <BackendResult <GroupData, ResultCode> > arg_2F_2; if ((arg_2F_2 = _9__1) == null) { arg_2F_2 = (_9__1 = delegate(BackendResult <GroupData, ResultCode> res) { this.SetInProgress(false, ""); this._isLoading = false; this._loaded = true; if (res.ResultCode == ResultCode.Succeeded) { this._group = res.ResultData.group; this.ReadData(); this.LoadWallData(reload, suppressLoading); } }); } arg_2F_0.GetGroupInfo(arg_2F_1, arg_2F_2); }); }
public void AddWaypointToDifferentGroupsTest() { var waypointsService = new WaypointsService(); var groupsService = new GroupsService(waypointsService); var wpt = new Waypoint("", GeoLocation.Empty); var group1 = new Group(""); var group2 = new Group(""); Assert.AreEqual(0, groupsService.Groups.Count); groupsService.Groups.Add(group1); groupsService.Groups.Add(group2); Assert.AreEqual(2, groupsService.Groups.Count); waypointsService.Waypoints.Add(wpt); Assert.IsTrue(groupsService.Groups.Contains(groupsService.DefaultGroup)); Assert.IsTrue(groupsService.DefaultGroup.Children.Contains(wpt)); group1.Children.Add(wpt); //groupsService.DefaultGroup.Children.Remove(wpt); Assert.IsFalse(groupsService.Groups.Contains(groupsService.DefaultGroup)); Assert.IsTrue(waypointsService.Waypoints.Contains(wpt)); group1.Children.Remove(wpt); Assert.IsFalse(waypointsService.Waypoints.Contains(wpt)); }
public App() { var waypointsService = new WaypointsService(); var groupsService = new GroupsService(waypointsService); GeoLayoutBuildingService = new GeoLayoutBuildingService(waypointsService, groupsService); SettingsService = new SettingsService(); var importService = new ImportService( new List <IGeoImporter>(new [] { new GpxImporter() }), new MultiFileDialogService(Current.MainWindow), waypointsService); var exportService = new ExportService( new List <IGeoExporter>(new [] { new GpxExporter() }), new SaveFileDialogService(Current.MainWindow), waypointsService); MainViewModel = new MainViewModel(importService, exportService, waypointsService, groupsService, GeoLayoutBuildingService); MapViewModel = new MapViewModel(waypointsService, groupsService, GeoLayoutBuildingService); GroupsViewModel = new GroupsViewModel(groupsService, waypointsService); }
private void SubscribeUnsubscribe_OnTapped(object sender, System.Windows.Input.GestureEventArgs e) { if (this.GameGroupId == 0L || (!this.IsSubscribed.HasValue || this._isLoading)) { return; } this._isLoading = true; GroupsService current = GroupsService.Current; if (this.IsSubscribed.Value) { current.Leave(this.GameGroupId, (Action <BackendResult <OwnCounters, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() => { this.IsSubscribed = new bool?(false); this._isLoading = false; })))); } else { current.Join(this.GameGroupId, false, (Action <BackendResult <OwnCounters, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() => { this.IsSubscribed = new bool?(true); this._isLoading = false; }))), null); } }
private void Actualiser() { GroupsService groupsService = new GroupsService(); groupeBindingSource.DataSource = null; groupeBindingSource.DataSource = groupsService.FindAll(); }
public ActionResult Edit() { GroupsService groupService = new GroupsService(); GroupEditVM model = new GroupEditVM(); TryUpdateModel(model); if (!ModelState.IsValid) { return(View(model)); } Group g; if (model.ID != 0) { g = groupService.GetByID(model.ID); } else { g = new Group(); } if (g == null) { return(this.RedirectToAction(c => c.List())); } Mapper.Map(model, g); groupService.Save(g); return(this.RedirectToAction(c => c.List())); }
public Importacao() { _groupsService = new GroupsService(); _plannetService = new PlannerService(); _context = new ImportacaoContext(); _usersService = new UsersService(); }
// GET: Groups public ActionResult List() { GroupsService groupService = new GroupsService(); GroupListVM model = new GroupListVM(); TryUpdateModel(model); //model.Groups = groupService.GetAll(); model.Groups = new Dictionary <Group, IEnumerable <SelectListItem> >(); foreach (var group in groupService.GetAll()) { IEnumerable <SelectListItem> contacts = groupService.GetContactsByGroup(group); model.Groups.Add(group, contacts); } if (model.Search != null) { model.Groups = model.Groups.Where(g => g.Key.Name.Contains(model.Search)).ToDictionary(v => v.Key, v => v.Value); } switch (model.SortOrder) { case "name_desc": model.Groups = model.Groups.OrderByDescending(g => g.Key.Name).ToDictionary(v => v.Key, v => v.Value); break; case "name_asc": default: model.Groups = model.Groups.OrderBy(g => g.Key.Name).ToDictionary(v => v.Key, v => v.Value); break; } return(View(model)); }
public ActionResult Edit(int?id) { GroupsService groupService = new GroupsService(); GroupEditVM model = new GroupEditVM(); Group group; if (id.HasValue) { group = groupService.GetByID(id.Value); if (group == null) { return(this.RedirectToAction(c => c.List())); } } else { group = new Group(); } Mapper.Map(group, model); return(View(model)); }
public ActionResult Edit() { GroupsService groupsService = new GroupsService(); GroupsEditVM model = new GroupsEditVM(); TryUpdateModel(model); Group group; if (model.ID == 0) { group = new Group(); } else { group = groupsService.GetByID(model.ID); if (group == null) { return(this.RedirectToAction(c => c.List())); } } if (!ModelState.IsValid) { return(View(model)); } Mapper.Map(model, group); group.UserID = AuthenticationManager.LoggedUser.ID; groupsService.Save(group); return(this.RedirectToAction(c => c.List())); }
public ActionResult List() { GroupsService groupsService = new GroupsService(); GroupsListVM model = new GroupsListVM(); TryUpdateModel(model); model.Groups = new Dictionary <Group, List <SelectListItem> >(); foreach (var group in groupsService.GetAll().Where(g => g.UserID == AuthenticationManager.LoggedUser.ID)) { List <SelectListItem> contacts = groupsService.GetSelectedContacts(group).ToList(); model.Groups.Add(group, contacts); } if (!String.IsNullOrEmpty(model.Search)) { model.Groups = model.Groups.Where(g => g.Key.Name.ToLower().Contains(model.Search.ToLower())).ToDictionary(v => v.Key, v => v.Value); } switch (model.SortOrder) { case "name_desc": model.Groups = model.Groups.OrderByDescending(g => g.Key.Name).ToDictionary(v => v.Key, v => v.Value); break; case "name_asc": default: model.Groups = model.Groups.OrderBy(g => g.Key.Name).ToDictionary(v => v.Key, v => v.Value); break; } return(View(model)); }
public JsonResult Add(int[] contactIDs, int groupID) { UnitOfWork unitOfWork = new UnitOfWork(); GroupsService groupsService = new GroupsService(unitOfWork); if (contactIDs == null) { contactIDs = new int[0]; } Group group = groupsService.GetByID(groupID); group.Contacts.Clear(); foreach (var id in contactIDs) { Contact contact = new ContactsService(unitOfWork).GetByID(id); group.Contacts.Add(contact); } groupsService.Save(group); var contacts = group.Contacts.Select(c => new { id = c.ID, firstName = c.FirstName, lastName = c.LastName }); return(Json(contacts, JsonRequestBehavior.AllowGet)); }
private IEnumerator _AddOwnership() { User currentUser = UserService.user; int groupId = GroupsService.group._id; bool isAdmin = true; WWW createRequest = GroupsService.AddMember(currentUser.email, groupId, isAdmin); while (!createRequest.isDone) { yield return(new WaitForSeconds(0.1f)); } AlertsService.removeLoadingAlert(); Debug.Log("Header: " + createRequest.responseHeaders["STATUS"]); Debug.Log("Text: " + createRequest.text); if (createRequest.responseHeaders["STATUS"] == HTML.HTTP_200) { LoadView("Groups"); } else { AlertsService.makeAlert("Erro", "Falha em sua conexão. Tente novamente mais tarde.", ""); yield return(new WaitForSeconds(3f)); LoadView("Groups"); } yield return(null); }
private IEnumerator _UpdateGroupInfo() { Group currentGroup = GroupsService.group; WWW updateRequest = GroupsService.UpdateGroup(currentGroup); while (!updateRequest.isDone) { yield return(new WaitForSeconds(0.1f)); } AlertsService.removeLoadingAlert(); Debug.Log("Header: " + updateRequest.responseHeaders["STATUS"]); Debug.Log("Text: " + updateRequest.text); if (updateRequest.responseHeaders["STATUS"] == HTML.HTTP_200) { UpdateFields(); } else { AlertsService.makeAlert("Falha ao atualizar", "Houve uma falha em sua conexão. Tente novamente mais tarde.", "Entendi"); } yield return(null); }
public GroupsServiceTests() { _fixture = new Fixture(); _fixture.Behaviors.Add(new OmitOnRecursionBehavior()); _mockRepository = new Mock <IGroupsRepository>(); SUT = new GroupsService(_mockRepository.Object); }
private IEnumerator _AddMember() { AlertsService.makeLoadingAlert("Adicionando"); string userEmail = newMemberEmail.text; int groupId = GroupsService.group._id; bool isAdmin = false; WWW createRequest = GroupsService.AddMember(userEmail, groupId, isAdmin); while (!createRequest.isDone) { yield return(new WaitForSeconds(0.1f)); } AlertsService.removeLoadingAlert(); Debug.Log("Header: " + createRequest.responseHeaders["STATUS"]); Debug.Log("Text: " + createRequest.text); if (createRequest.responseHeaders["STATUS"] == HTML.HTTP_200) { AlertsService.makeAlert("Sucesso", "O usuário foi adicionado com sucesso em seu grupo.", ""); yield return(new WaitForSeconds(3f)); LoadView("Group"); yield return(null); } else { AlertsService.makeAlert("Falha ao adicionar", "Verifique se inseriu o endereço de e-mail do usuário corretamente.", "Entendi"); } yield return(null); }
public void GetGroups_ShouldReturn_NotNull() { // Arrange var groups = new List <GroupsModel> { new GroupsModel() }; List <GroupsDtoModel> groupsDtos = new List <GroupsDtoModel>(); fakeGroupsRepository.Setup(a => a.GetAll()).Returns(groups); groupsService = new GroupsService(fakeGroupsRepository.Object); try { // Act groupsDtos = (List <GroupsDtoModel>)groupsService.GetGroups(); operationSucceeded = true; } catch (Exception ex) { errorMessage = ex.Message + " | " + ex.StackTrace; } // Assert Assert.IsTrue(groupsDtos.Count > 0, errorMessage); }
private IEnumerator _GetGroupMembers() { int groupId = GroupsService.group._id; WWW membersRequest = GroupsService.GetMembers(groupId); while (!membersRequest.isDone) { yield return(new WaitForSeconds(0.1f)); } Debug.Log("Header: " + membersRequest.responseHeaders["STATUS"]); Debug.Log("Text: " + membersRequest.text); if (membersRequest.responseHeaders["STATUS"] == HTML.HTTP_200) { GroupsService.UpdateGroupMembers(membersRequest.text); CreateMembersCards(); } else { AlertsService.makeAlert("Falha na conexão", "Tente novamente mais tarde.", "Entendi"); LoadView("Home"); } yield return(null); }
public GroupsServiceTests() { AutoMapperConfig.RegisterMappings(Assembly.Load("HiWorld.Services.Data.Tests")); var mockImageService = new Mock <IImagesService>(); mockImageService.Setup(x => x.CreateAsync(It.IsAny <IFormFile>(), It.IsAny <string>())) .Returns(Task.Run(() => "test")); this.imagesService = mockImageService.Object; var connection = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()); this.dbContext = new ApplicationDbContext(connection.Options); this.dbContext.Database.EnsureCreated(); this.friendsRepository = new EfRepository <ProfileFriend>(this.dbContext); this.groupMembersRepository = new EfRepository <GroupMember>(this.dbContext); this.groupsRepository = new EfDeletableEntityRepository <Group>(this.dbContext); this.groupsService = new GroupsService( this.groupsRepository, this.groupMembersRepository, this.friendsRepository, this.imagesService); }
private IEnumerator _RemoveGroup() { AlertsService.makeLoadingAlert("Removendo"); int groupId = GroupsService.group._id; WWW removeRequest = GroupsService.RemoveGroup(groupId); while (!removeRequest.isDone) { yield return(new WaitForSeconds(0.1f)); } AlertsService.removeLoadingAlert(); Debug.Log("Header: " + removeRequest.responseHeaders["STATUS"]); Debug.Log("Text: " + removeRequest.text); if (removeRequest.responseHeaders["STATUS"] == HTML.HTTP_200) { LoadView("Groups"); } else { AlertsService.makeAlert("Falha ao remover", "Verifique sua conexão com a internet e tente novamente mais tarde.", "Entendi"); } yield return(null); }
private IEnumerator _RemoveMember() { AlertsService.makeLoadingAlert("Removendo"); WWW removeRequest = GroupsService.RemoveMember(member._id); while (!removeRequest.isDone) { yield return(new WaitForSeconds(0.1f)); } Debug.Log("Header: " + removeRequest.responseHeaders["STATUS"]); Debug.Log("Text: " + removeRequest.text); AlertsService.removeLoadingAlert(); if (removeRequest.responseHeaders["STATUS"] == HTML.HTTP_200) { if (isCurrentUser) { SceneManager.LoadScene("Groups"); } else { Destroy(this.gameObject); } yield return(null); } else { AlertsService.makeAlert("Falha na conexão", "Tente novamente mais tarde.", "Entendi"); } yield return(null); }
private async Task DeleteItemsAsync(IEnumerable <GroupsModel> models) { foreach (var model in models) { await GroupsService.DeleteGroupsAsync(model); } }
private IEnumerator _ExitGroup() { AlertsService.makeLoadingAlert("Saindo"); WWW exitRequest = GroupsService.RemoveMember(UserService.user._id); while (!exitRequest.isDone) { yield return(new WaitForSeconds(0.1f)); } Debug.Log("Header: " + exitRequest.responseHeaders["STATUS"]); Debug.Log("Text: " + exitRequest.text); AlertsService.removeLoadingAlert(); if (exitRequest.responseHeaders["STATUS"] == HTML.HTTP_200) { AlertsService.makeAlert("Sucesso", "Você saiu do grupo.", ""); yield return(new WaitForSeconds(2f)); SceneManager.LoadScene("Groups"); yield return(null); } else { AlertsService.makeAlert("Falha na conexão", "Tente novamente mais tarde.", "Entendi"); SceneManager.LoadScene("Home"); } yield return(null); }
private IEnumerator _GetGroups() { AlertsService.makeLoadingAlert("Recebendo grupos"); User currentUser = UserService.user; WWW groupsRequest = GroupsService.GetUserGroups(currentUser._id); while (!groupsRequest.isDone) { yield return(new WaitForSeconds(0.1f)); } Debug.Log("Header: " + groupsRequest.responseHeaders["STATUS"]); Debug.Log("Text: " + groupsRequest.text); if (groupsRequest.responseHeaders["STATUS"] == HTML.HTTP_200) { GroupsService.UpdateCurrentGroups(groupsRequest.text); CreateGroupsCards(); } else { AlertsService.makeAlert("Falha na conexão", "Tente novamente mais tarde.", ""); yield return(new WaitForSeconds(3f)); LoadView("Home"); } yield return(null); }
public RocketChat(string serverUrl) { IRestClient restClient = new RestClient(serverUrl); IJsonSerializer jsonSerializer = new JsonSerializer(); IAuthHelper authHelper = new AuthHelper(); IRestClientService restClientService = new RestClientService(authHelper, restClient, jsonSerializer); IFileRestClientService fileRestClientService = new FileRestClientService(authHelper, restClient, jsonSerializer); IAuthenticationService authService = new AuthenticationService(authHelper, restClientService); IChannelsService channelsService = new ChannelsService(restClientService); IGroupsService groupsService = new GroupsService(restClientService); IUsersService usersService = new UsersService(restClientService); IChatService chatService = new ChatService(restClientService); IRoomService roomService = new RoomService(restClientService); IAssetsService assetsService = new AssetsService(restClientService); IAutoTranslateService autoTranslateService = new AutoTranslateService(restClientService); ICommandsService commandsService = new CommandsService(restClientService); IEmojisService emojisService = new EmojisService(restClientService, fileRestClientService); Api = new RocketChatApi( chatService, usersService, groupsService, channelsService, authService, roomService, assetsService, autoTranslateService, commandsService, emojisService); }
private IEnumerator _CreateGroup() { if (!CheckFields()) { AlertsService.makeAlert("Campos inválidos", "Preencha os campos corretamente.", "OK"); yield break; } AlertsService.makeLoadingAlert("Criando grupo"); string groupName = newGroupName.text, groupDescription = newGroupDescription.text; WWW createRequest = GroupsService.CreateGroup(groupName, groupDescription); while (!createRequest.isDone) { yield return(new WaitForSeconds(0.1f)); } Debug.Log("Header: " + createRequest.responseHeaders["STATUS"]); Debug.Log("Text: " + createRequest.text); if (createRequest.responseHeaders["STATUS"] == HTML.HTTP_200) { GroupsService.UpdateCurrentGroup(createRequest.text); yield return(StartCoroutine(_AddOwnership())); } else { AlertsService.makeAlert("Falha na conexão", "Tente novamente mais tarde.", "Entendi"); } yield return(null); }
private static void CreateGroup() { Console.WriteLine(); if (!ValidateContextPreGroupCreation()) { return; } Console.WriteLine("Start Group Creation..."); var group = GenerateGroup(); var createdGroups = GroupsService.CreateGroups( ApiContext.CompanyGuid.Value, new[] { group } ); Console.WriteLine(); if (createdGroups == null || createdGroups.Length == 0) { Console.WriteLine("Error Occurred During Creating Group."); return; } _createdGroup = createdGroups[0]; Console.WriteLine($"Finished Group Creation. New Group Id: {_createdGroup.Id}"); }
public async Task EditeAsyncWithDublicateNameShouldThrowArgumentException() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var cloudinary = new Mock <ICloudinaryService>(); var concertGroupsRepository = new EfRepository <ConcertGroup>(dbContext); var groupsRepository = new EfDeletableEntityRepository <Group>(dbContext); var groupGenresRepository = new EfRepository <GroupGenre>(dbContext); var usertGroupsRepository = new EfRepository <UserGroup>(dbContext); var groupService = new GroupsService(concertGroupsRepository, groupsRepository, groupGenresRepository, usertGroupsRepository, cloudinary.Object); var photo = new Mock <IFormFile>(); await groupService.CreateAsync("Sabaton", photo.Object, "description"); var id = await groupService.CreateAsync("Nightwish", photo.Object, "description"); var model = new GroupEditInputModel { Name = "Sabaton", Photo = photo.Object, Description = "description", }; await Assert.ThrowsAsync <ArgumentException>(async() => { await groupService.EditAsync(id, model); }); }