コード例 #1
0
        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));
        }
コード例 #2
0
        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."));
        }
コード例 #3
0
ファイル: GroupService.cs プロジェクト: scollier90/BookLeague
        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
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 //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);
 }
コード例 #6
0
        public IHttpActionResult CreateGroup(GroupCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service         = GetGroupService();
            var requestResponse = service.CreateGroup(model);

            return(ValidateRequestResponse(requestResponse));
        }
コード例 #7
0
ファイル: Startup.cs プロジェクト: JTux/ChoreTrackerAPI
        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);
            }
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        public async Task InsertAsync(GroupCreate model)
        {
            var entity = _mapper.Map <GroupEntity>(Has.NotNull(model));

            await _unitOfWork.Groups.InsertAsync(entity);
        }
コード例 #12
0
 public CreateModel(ProgressContext context)
 {
     _useCase = new GroupCreate(context);
 }