Exemplo n.º 1
0
        /// <summary>
        /// Adss the group information to the underlying group repository
        /// </summary>
        /// <param name="model"></param>
        private void AddGroup(GroupCreationBlockViewModel model)
        {
            var validatedInputs = ValidateGroupInputs(model.Name, model.Description);

            if (validatedInputs)
            {
                try
                {
                    //Add the group and persist the group name in temp data to be used in the success message
                    var group    = new Social.Models.Groups.Community(model.Name, model.Description);
                    var newGroup = _communityRepository.Add(group);
                    if (model.IsModerated)
                    {
                        _moderationRepository.AddWorkflow(newGroup);
                    }
                    var message = "Your group: " + model.Name + " was added successfully!";
                    AddMessage(MessageKey, new MessageViewModel(message, SuccessMessage));
                }
                catch (SocialRepositoryException ex)
                {
                    //Persist the exception message in temp data to be used in the error message
                    AddMessage(MessageKey, new MessageViewModel(ex.Message, ErrorMessage));
                }
            }
            else
            {   //Persist the exception message in temp data to be used in the error message
                var message = "Group name and description cannot be empty";
                AddMessage(MessageKey, new MessageViewModel(message, ErrorMessage));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Validates that the group returned exists
 /// </summary>
 /// <param name="blockModel">The view model for the GroupAdmissionBlock</param>
 /// <param name="group">The group that was retrieved</param>
 private void ValidateGroup(GroupAdmissionBlockViewModel blockModel, Social.Models.Groups.Community group)
 {
     if (group != null)
     {
         var groupId = group.Id;
         blockModel.GroupName   = group.Name;
         blockModel.GroupId     = groupId.ToString();
         blockModel.IsModerated = _moderationRepository.IsModerated(groupId);
     }
     else
     {
         var errorMessage = "The group configured for this block cannot be found. Please update the block to use an existing group.";
         AddMessage(MessageKey, new MessageViewModel(errorMessage, ErrorMessage));
     }
 }