示例#1
0
        public ActionResult Create(PeanutCreateCommand peanutCreateCommand, User currentUser)
        {
            Require.NotNull(peanutCreateCommand, "peanutCreateCommand");
            Require.NotNull(currentUser, "currentUser");

            if (!ModelState.IsValid)
            {
                List <UserGroupMembership> userGroupMemberships =
                    UserGroupService.FindMembershipsByUser(PageRequest.All, currentUser, _activeUsergroupMembershipTypes).ToList();
                List <UserGroup> userGroups = userGroupMemberships.Select(membership => membership.UserGroup).ToList();
                List <PeanutParticipationType> participationTypes = PeanutParticipationTypeService.GetAll(PageRequest.All).ToList();
                return(View("Create", new PeanutCreateViewModel(userGroups)));
            }

            /*Initiale Teilnehmer ermitteln.*/
            IDictionary <UserGroupMembership, PeanutParticipationDto> initialParticators = new Dictionary <UserGroupMembership, PeanutParticipationDto>();
            Peanut peanut = PeanutService.Create(peanutCreateCommand.UserGroup,
                                                 peanutCreateCommand.PeanutDto,
                                                 peanutCreateCommand.Requirements.Values.ToList(),
                                                 initialParticators,
                                                 currentUser);

            return(RedirectToAction("Show", new { peanut = peanut.BusinessId }));
        }