public IHttpActionResult CreateGroup([FromBody] RegisterGroup newGroup) { Group group = new Group(); group.Owner_Id = RequestContext.Principal.Identity.GetUserId(); group.Name = newGroup.Name; group.Description = newGroup.Description; IEnumerable <Station> stations = _stationsRepo.GetMultipleStations(newGroup.StationIds); group.Stations = new Collection <Station>(stations.ToList()); group = _repo.CreateGroup(group); return(Ok(group)); }
public ActionResult Create([Bind(Include = "Name,Description")] GroupViewModel group) { if (ModelState.IsValid) { string userId = User.Identity.GetUserId(); Group grp = new Group(group) { Description = group.Description }; _groupRepo.CreateGroup(grp, UserManager.FindById(userId)); return(RedirectToAction("Index")); } return(View(group)); }
public void CreateGroup() { // In-memory database only exists while the connection is open var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <ScrumContext>() .UseSqlite(connection) .Options; // Create the schema in the database using (var context = new ScrumContext(options)) { context.Database.EnsureCreated(); } // Run the test against one instance of the context using (var context = new ScrumContext(options)) { var service = new GroupRepository(context); Group group = new Group(); GroupMember groupMember = new GroupMember(); groupMember.user.username = "******"; groupMember.role = "Developer"; GroupMember groupMember2 = new GroupMember(); groupMember2.user.username = "******"; groupMember2.role = "Product Owner"; group.AddMember(groupMember); group.AddMember(groupMember2); var created = service.CreateGroup(group); Assert.AreEqual(true, created); // Assert.AreEqual(2, context.GroupMembers.Count()); // Assert.AreEqual(2, context.GroupMembers.Find("Andrew").GroupId); } } finally { connection.Close(); } }
public async void CreateGroup_ThrowBreadException_When_InvalidIssuer() { using (var applicationDbContext = TestTools.CreateApplicationDbContext()) { // Arrange string fakeIssuerId = "277AAEEC-AC90-4B0E-B1D3-C318AEF1A95C"; // No user created for fakeIssuerId // Act await Assert.ThrowsAsync <BreadException>(async() => { var sut = new GroupRepository(applicationDbContext); var group = await sut.CreateGroup(fakeIssuerId, new Domain.Dto.GroupInfo { Name = "Name for Group", MissionStatement = "MissionStatement for Group" }); // Assert Assert.True(false, "sut.CreateGroup failed to raise exception as expected"); }); } }
public async void CreateGroup_Pass_When_ValidInput() { using (var applicationDbContext = TestTools.CreateApplicationDbContext()) { // Arrange string issuerId = "277AAEEC-AC90-4B0E-B1D3-C318AEF1A95C"; applicationDbContext.Add(new ApplicationUser { Id = issuerId, UserName = "******" }); // Act var sut = new GroupRepository(applicationDbContext); var group = await sut.CreateGroup(issuerId, new Domain.Dto.GroupInfo { Name = "Name for Group", MissionStatement = "Descriptio for Group" }); // Assert Assert.NotNull(group); } }
public void TestCreateGroup() { var start = DateTime.Now; var end = DateTime.Now.AddYears(2); const int groupId = 854725; var newGroup = new MpGroup() { Name = "New Testing Group", GroupDescription = "The best group ever created for testing stuff and things", GroupType = 19, MinistryId = 8, ContactId = 74657, CongregationId = 1, StartDate = start, EndDate = end, Full = false, AvailableOnline = true, RemainingCapacity = 8, WaitList = false, ChildCareAvailable = false, MeetingDayId = 2, MeetingTime = "15:15:00", GroupRoleId = 16, MinimumAge = 0, MinimumParticipants = 8, MaximumAge = 99, KidsWelcome = false, MeetingFrequencyID = null, Address = new MpAddress() { Address_ID = 43567 } }; var values = new Dictionary <string, object> { { "Group_Name", "New Testing Group" }, { "Group_Type_ID", 19 }, { "Ministry_ID", 8 }, { "Congregation_ID", 1 }, { "Primary_Contact", 74657 }, { "Description", "The best group ever created for testing stuff and things" }, { "Start_Date", start }, { "End_Date", end }, { "Target_Size", 0 }, { "Offsite_Meeting_Address", 43567 }, { "Group_Is_Full", false }, { "Available_Online", true }, { "Meeting_Time", "15:15:00" }, { "Meeting_Day_Id", 2 }, { "Domain_ID", 1 }, { "Child_Care_Available", false }, { "Remaining_Capacity", 8 }, { "Enable_Waiting_List", false }, { "Online_RSVP_Minimum_Age", 0 }, { "Maximum_Age", 99 }, { "Minimum_Participants", 8 }, { "Kids_Welcome", false }, { "Meeting_Frequency_ID", null } }; _ministryPlatformService.Setup(mocked => mocked.CreateRecord(322, It.IsAny <Dictionary <string, object> >(), "ABC", true)).Returns(groupId); int resp = _fixture.CreateGroup(newGroup); _ministryPlatformService.Verify(mocked => mocked.CreateRecord(322, values, "ABC", true)); Assert.IsNotNull(resp); Assert.AreEqual(groupId, resp); }
public void AddGroup(string groupName, List <UserEntity> users) { objGR.CreateGroup(groupName, users); }
public static SimpleGroup CreateGroup(string groupName, int ownerId) { string uniqueName = Guid.NewGuid().ToString(); return(GroupRepository.CreateGroup(uniqueName, groupName, ownerId)); }
public bool CreateGroup(Group group) { return(_groupRepository.CreateGroup(group)); }