private async Task <Result> ActUseCase(Func <GroupCreate, Task <Result> > action) { await using var dbContext = Fixture.CreateDbContext(); var useCase = new GroupCreate(dbContext); return(await action(useCase)); }
public RequestResponse CreateGroup(GroupCreate model) { if (model == null) { return(BadResponse("Request Body was empty.")); } var groupEntity = new GroupEntity(model.GroupName, _userId, GetNewRandomKey(8)); _context.Groups.Add(groupEntity); if (_context.SaveChanges() != 1) { return(BadResponse("Could not create group")); } var memberEntity = new GroupMemberEntity(groupEntity.GroupId, _userId.ToString(), true, true); _context.GroupMembers.Add(memberEntity); if (_context.SaveChanges() != 1) { return(BadResponse("Could not create group member.")); } return(OkResponse("Group created successfully.")); }
public bool CreateGroup(GroupCreate model) { var entity = new Group() { GroupName = model.GroupName, CreatorId = _creatorId, Id = _creatorId.ToString() }; using (var ctx = new ApplicationDbContext()) { ctx.Groups.Add(entity); return(ctx.SaveChanges() == 1); } //using (var ctx = new ApplicationDbContext()) //{ // ctx.Groups.Add(entity); // if (ctx.SaveChanges() == 1) // { // entity.Users.Add(RetrieveUserById(_creatorId)); //insert method call here) // return true; // } // return false; //} //Method that: Retrieve ApplicationUser object by ID }
public async Task <Group> CreateGroup([FromBody] GroupCreate groupCreate) { Group group = new Group() { Name = groupCreate.Name }; await dataBaseContext.Groups.AddAsync(group); await dataBaseContext.SaveChangesAsync(); return(group); }
//create new permission group public void CreateGroupApplication() { GroupCreate.ClickOn(); softAssert.VerifyElementPresentInsideWindow(GroupCancel, GroupCancel); GroupName.EnterClearText("11"); GroupSave.ClickOn(); softAssert.VerifyElementPresentInsideWindow(GroupNameError, GroupCancel); GroupName.EnterClearText(Constant.groupName + RandomNumber.smallNumber()); Thread.Sleep(500); GroupSave.ClickOn(); softAssert.VerifyElementHasEqual(utility.ListCount(countGroupList), Constant.tmpListCount + 1); }
public IHttpActionResult CreateGroup(GroupCreate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = GetGroupService(); var requestResponse = service.CreateGroup(model); return(ValidateRequestResponse(requestResponse)); }
private void CreateAdminGroup() { var context = new ApplicationDbContext(); if (context.Groups.FirstOrDefault(g => g.GroupName == "Admin Group") == null) { var adminUser = context.Users.FirstOrDefault(u => u.Email == "*****@*****.**"); var groupService = new GroupService(Guid.Parse(adminUser.Id)); var adminGroupCreate = new GroupCreate { GroupName = "Admin Group" }; groupService.CreateGroup(adminGroupCreate); } }
public bool CreateGroup(GroupCreate model) { var group = new Group() { OwnerID = _userID, Name = model.Name, TripType = model.TripType, GuestCount = model.GuestCount }; using (var ctx = new ApplicationDbContext()) { ctx.Groups.Add(group); return(ctx.SaveChanges() == 1); } }
public bool CreateGroup(GroupCreate model) { var entity = new Group() { GroupName = model.GroupName, OwnerID = _userId }; using (var ctx = new ApplicationDbContext()) { ctx.Groups.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(GroupCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateGroupService(); if (service.CreateGroup(model)) { TempData["SaveResult"] = "Your group was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Group could not be created."); return(View(model)); }
public async Task InsertAsync(GroupCreate model) { var entity = _mapper.Map <GroupEntity>(Has.NotNull(model)); await _unitOfWork.Groups.InsertAsync(entity); }
public CreateModel(ProgressContext context) { _useCase = new GroupCreate(context); }