public IGroup CreateGroup(string groupName) { // call this constructor doesn't fire the group changed event DbGroup createdGroup = new DbGroup(groupName); createdGroup.AssignStores(this.groups, this.dispatcher, this.favorites); return createdGroup; }
public void LongDbGroupName_ValidateNameOnly_ReturnsNameError() { var group = new DbGroup(); group.Name = LongText; AssertNameOnlyValidation(this.validator, group); }
private DbGroup AddNewGroupToPrimaryPersistence(string newGroupName) { DbGroup testGroup = this.CreateNewTestGroup(newGroupName); this.PrimaryPersistence.Groups.Add(testGroup); return(testGroup); }
public static Group Convert(this DbGroup group) { return(new Group() { Id = group.GroupId, Name = group.Name }); }
public DBAL() { this.SQL = AnySQL.CreateInstance(); this.User = new DbUser(this.SQL); this.Group = new DbGroup(this.SQL); this.UserGroupMapping = new DbUserGroupMapping(this.SQL); }
public int AddGroup(string name) { var item = Context.Groups.FirstOrDefault(x => x.Name == name); if (item != null) { return(item.GroupId); } item = new DbGroup() { Name = name }; Context.Groups.Add(item); try { Context.SaveChanges(); } catch (Exception ex) { Debug.WriteLine($"Exception:{ex.Message}"); return(-1); } return(item.GroupId); }
public async Task ShouldUpdateGroup() { //Given var updateGroupRequest = _fixture.Create <UpdateGroupRequest>(); var dbGroup = new DbGroup(); _unitOfWorkMock .Setup(r => r.GroupRepository.UpdateAsync(It.IsAny <DbGroup>())) .Callback((DbGroup s) => { dbGroup = s; }) .Returns(Task.CompletedTask).Verifiable(); var sut = CreateSut(); //When await sut.UpdateGroupAsync(updateGroupRequest); //Then _unitOfWorkMock.VerifyAll(); dbGroup.Name.Should().Be(updateGroupRequest.Name); }
public void AddGroup_AddsToDatabase() { DbGroup childGroup = this.AddGroupAToPrimaryPersistence(); DbSet <DbGroup> checkedGroups = this.CheckDatabase.Groups; DbGroup checkedChild = checkedGroups.FirstOrDefault(group => group.Id == childGroup.Id); Assert.IsNotNull(checkedChild, "Group wasn't added to the database"); }
/// <summary> /// Returns the newly created groups in Primary persistence. Item1 = Parent, Item2 = Child. /// </summary> private Tuple <DbGroup, DbGroup> AssignParentToChildGroup() { DbGroup childGroup = this.AddGroupAToPrimaryPersistence(); DbGroup parentGroup = this.AddNewGroupToPrimaryPersistence("TestGroupB"); childGroup.Parent = parentGroup; // don't use entities here, we are testing intern logic this.PrimaryPersistence.Groups.Update(childGroup); return(new Tuple <DbGroup, DbGroup>(parentGroup, childGroup)); }
public static string ConvertGroupToSourceId(DbGroup _group) { if (!string.IsNullOrWhiteSpace(_group.GroupPrefix)) { return($"{_group.GroupPrefix}{_group.GroupId}"); } return(_group.GroupId.ToString()); }
public void UpdateGroup_SavesParentPropertyToDatabase() { Tuple <DbGroup, DbGroup> created = this.AssignParentToChildGroup(); DbGroup checkedParent = this.FindCheckedGroupById(created.Item1.Id); DbGroup checkedChild = this.FindCheckedGroupById(created.Item2.Id); Assert.IsNotNull(checkedChild, "Child group wasn't added to the database"); Assert.IsNotNull(checkedParent, "Parent group wasn't added to the database"); Assert.AreEqual(1, checkedParent.ChildGroups.Count, "Group wasn't added as child"); }
async Task AddGroup(string name, string description) { var newGroup = new DbGroup { Name = name, Description = description, Type = "THEMECAMP" }; await Context.AddAsync(newGroup); }
public void AddGroup_SavesParentToDatabase() { DbGroup parentGroup = this.AddNewGroupToPrimaryPersistence("TestGroupB"); // dont save the group before parent is assigned. DbGroup childGroup = this.CreateNewTestGroup("TestGroupA"); childGroup.Parent = parentGroup; // don't use entities here, we are testing intern logic this.PrimaryPersistence.Groups.Add(childGroup); var checkedChild = this.FindInSecondaryPersistence(childGroup.Id); Assert.IsNotNull(checkedChild.Parent, "Newly added group parent wasnt saved to the database."); }
public void UpdateGroup_UpdatesName() { DbGroup childGroup = this.AddGroupAToPrimaryPersistence(); const string NEWNAME = "UpdatedName"; childGroup.Name = NEWNAME; this.PrimaryPersistence.Groups.Update(childGroup); DbGroup checkedChild = this.FindCheckedGroupById(childGroup.Id); Assert.IsNotNull(checkedChild, "Group wasn't added to the database"); Assert.AreEqual(NEWNAME, checkedChild.Name, "Group name wasnt update properly"); }
private void ButtonNewGenerator(object sender, RoutedEventArgs e) { DbGroup dbgroup = new DbGroup(); var groups = dbgroup.ReadAll(Data.Code); if (groups.Count == 0) { MessageBox.Show("Please add one group first!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { AddNewGeneratorWindow add = new AddNewGeneratorWindow(); add.Show(); } }
private void Button_Click(object sender, RoutedEventArgs e) { DbGroup dbGroup = new DbGroup(); DbLocalController dblc = new DbLocalController(); Group group = new Group(); group.LCCode = Data.Code; group.Name = txt_box_kod.Text; group.MaxProduction = 0; group.NumOfUnits = 0; group.CurrentProduction = 0; dbGroup.Create(group); Close(); }
public void AddGroupToUser(string _key, Group _group) { if (string.IsNullOrWhiteSpace(_key)) { throw new ArgumentException("Key can not be null or white space!", nameof(_key)); } if (_group == null) { throw new ArgumentNullException(nameof(_group)); } using (var context = new GrabberDbContext()) { var dbUser = context.DbUsers.FirstOrDefault(_dbUser => _dbUser.Key == _key); if (dbUser == null) { throw new ArgumentException($"User with key {_key} not found!"); } var existedGroup = context.DbGroups.FirstOrDefault(_dbGroup => _dbGroup.GroupId == _group.GroupId && _dbGroup.DbUser.Id == dbUser.Id); if (existedGroup == null) { var dbGroup = new DbGroup { GroupId = _group.GroupId, GroupPrefix = _group.Prefix, GroupName = _group.Name, UpdatePeriod = _group.UpdatePeriod, DbUser = dbUser, LastUpdateDateTime = DateTime.Now.ToUniversalTime() }; context.DbGroups.Add(dbGroup); } else { throw new ArgumentException($"User already has group with id {_group.GroupId}"); } context.SaveChanges(); } }
public void Create(Group group) { _dbGroup = new DbGroup(); }
public static DbGroup Get(AnySQL sql, string groupName) { DbGroup dbGroup = new DbGroup(sql); return(dbGroup); }
public static DbGroup Get(AnySQL sql, int groupId) { DbGroup dbGroup = new DbGroup(sql); return(dbGroup); }
public GroupController() { dbGroup = new DbGroup(); dbActivity = new DbActivity(); profileController = new ProfileController(); }