Ejemplo n.º 1
0
        public static Result SaveUser(MELib.Security.User user)
        {
            if (user.SecurityGroupUserList.Count == 0)
            {
                //add a default security group of General User
                SecurityGroupUser securityGroupUser = SecurityGroupUser.NewSecurityGroupUser();
                securityGroupUser.SecurityGroupID = ROSecurityGroupList.GetROSecurityGroupList(true).FirstOrDefault(c => c.SecurityGroup == "General User")?.SecurityGroupID;
                user.SecurityGroupUserList.Add(securityGroupUser);
            }

            user.LoginName = user.EmailAddress;

            Result results     = new Singular.Web.Result();
            Result Saveresults = user.SaveUser(user);

            MELib.Security.User SavedUser = (MELib.Security.User)Saveresults.Data;

            if (SavedUser != null)
            {
                results.Success = true;
                results.Data    = SavedUser;
            }
            else
            {
                results.Success   = false;
                results.ErrorText = Saveresults.ErrorText;
            }
            return(results);
        }
Ejemplo n.º 2
0
        public static Result CreateQuestionnaireAnswerSet(int QuestionnaireID)
        {
            Result results = new Singular.Web.Result();

            //Get published questionnaire first to create duplicate
            var pQuestionnaireID = METTLib.Questionnaire.QuestionnaireList.GetQuestionnaireList().First(c => c.PublishInd == true && c.IsDeleted == false).QuestionnaireID;

            if (pQuestionnaireID != 0)
            {
                //Get values to duplicate
                var pQuestionnaireName          = METTLib.Questionnaire.QuestionnaireList.GetQuestionnaireList().First(c => c.PublishInd == true && c.IsDeleted == false).QuestionnaireName;
                var pQuestionnaireVersionNumber = METTLib.Questionnaire.QuestionnaireList.GetQuestionnaireList().First(c => c.PublishInd == true && c.IsDeleted == false).QuestionnaireVersionNumber;
                var pStartDate       = METTLib.Questionnaire.QuestionnaireList.GetQuestionnaireList().First(c => c.PublishInd == true && c.IsDeleted == false).StartDate;
                var pEndDate         = METTLib.Questionnaire.QuestionnaireList.GetQuestionnaireList().First(c => c.PublishInd == true && c.IsDeleted == false).EndDate;
                var pPublishDateTime = METTLib.Questionnaire.QuestionnaireList.GetQuestionnaireList().First(c => c.PublishInd == true && c.IsDeleted == false).PublishDateTime;

                var newQuestionnaireList = METTLib.Questionnaire.QuestionnaireList.NewQuestionnaireList();
                //Create empty questionnaire object to duplicate
                var newQuestionnaire = new METTLib.Questionnaire.Questionnaire
                {
                    //Set new object values
                    QuestionnaireName          = "Copy of [ " + pQuestionnaireName + " - " + pQuestionnaireVersionNumber + " ]",
                    QuestionnaireVersionNumber = "",
                    StartDate       = DateTime.Now,
                    EndDate         = DateTime.Now.AddYears(1),
                    PublishDateTime = DateTime.Now,
                    PublishInd      = false
                };
                //Save new questionnaire (1)
                if (newQuestionnaire.IsValid)
                {
                    Singular.SaveHelper SaveNewQuestionnaireSaveHelper       = newQuestionnaire.TrySave(typeof(METTLib.Questionnaire.QuestionnaireList));
                    METTLib.Questionnaire.Questionnaire SaveNewQuestionnaire = (METTLib.Questionnaire.Questionnaire)SaveNewQuestionnaireSaveHelper.SavedObject;
                    //SaveNewQuestionnaire.QuestionnaireID
                    if (SaveNewQuestionnaireSaveHelper.Success)
                    {
                        //Update and return list object
                        results.Data    = METTLib.Questionnaire.QuestionnaireList.GetQuestionnaireList();
                        results.Success = true;
                    }
                }
            }
            return(results);
        }
Ejemplo n.º 3
0
        public static Result DeleteUser(int userId, Boolean RemoveAssociations)
        {
            Result results = new Singular.Web.Result();

            try
            {
                //get the user object and soft delete the user
                MELib.Security.UserList userList = MELib.Security.UserList.GetUserList(userId);
                userList.RemoveAt(0);
                userList.Save();

                results.Success = true;
            }
            catch (Exception ex)
            {
                results.ErrorText = ex.Message;
                results.Success   = false;
            }

            return(results);
        }