public IHttpActionResult UpdateAdminUserForParent(JObject jsonResult)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                string Message = string.Empty;
                UserBO objUser = new UserBO();

                if (identity.Role == ConstantMessages.Roles.companyadmin || identity.Role == ConstantMessages.Roles.superadmin)
                {
                    int ChildUserID = 0;
                    if (jsonResult.SelectToken("UserID") != null && jsonResult.SelectToken("UserID").ToString().Trim() != "")
                    {
                        ChildUserID = (int)jsonResult.SelectToken("UserID");

                        if (ValidateUserDetails(identity.Role, identity.CompId, jsonResult, out Message, out objUser, "update", ChildUserID))
                        {
                            objUser.UserID = identity.UserID;
                            objUser.CompId = identity.CompId;
                            objUser.Role   = identity.Role;

                            var ds = OrganizationBL.CreateUpdateAdminUser(objUser, 2, ChildUserID);
                            if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["ReturnCode"].ToString() == "1")
                            {
                                data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                                data = Utility.Successful(data);
                            }
                            else if (ds.Tables[0].Rows.Count > 0)
                            {
                                data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                                data = Utility.Failed(data);
                            }
                            else
                            {
                                data = Utility.API_Status("0", ConstantMessages.WebServiceLog.GenericErrorMsg);
                            }
                        }
                        else
                        {
                            data = Utility.API_Status("2", Message);
                        }
                    }
                    else
                    {
                        data = Utility.API_Status("2", "Please provide UserID");
                    }
                }
                else
                {
                    data = Utility.API_Status("3", "You do not have access for this functionality");
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult GetMsgNotifications()
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                string Message = string.Empty;

                DataSet ds = TrainningBL.GetMsgNotifications(identity.CompId, identity.UserID.ToString(), 5);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    //data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                    data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                    data = Utility.Successful(data);
                }
                else
                {
                    data = Utility.API_Status("0", "No data found");
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult DeleteQuestion(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    var compId = identity.CompId;
                    var userId = identity.UserID;
                    var questionId = 0; var isMandatory = true; var isMultiline = true;
                    var contentId = 0; var title = ""; var qType = 0;
                    var isBox         = false;
                    var contentTypeId = Convert.ToInt32(Convert.ToString(requestParams["ContentTypeID"]));
                    var action        = Convert.ToInt32(Convert.ToString(requestParams["Action"]));
                    var type          = Convert.ToInt32(Convert.ToString(requestParams["Type"]));
                    if (!string.IsNullOrEmpty(Convert.ToString(requestParams["QuestionID"])))
                    {
                        questionId = Convert.ToInt32(requestParams["QuestionID"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString(requestParams["ContentID"])))
                    {
                        contentId = Convert.ToInt32(requestParams["ContentID"]);
                    }

                    var ds = QuizBL.ManageQuestion(compId, userId, questionId, contentId, isMandatory, isMultiline, title, qType, isBox, action);
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["ReturnCode"].ToString() == "1")
                    {
                        var dsQuestion = QuizBL.ManageQuestion(compId, userId, questionId, contentId, isMandatory, isMultiline, title, qType, isBox, 4);
                        data = Utility.ConvertDataSetToJSONString(dsQuestion);
                        data = Utility.Successful(data);
                    }
                    else if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["ReturnCode"].ToString() != "1")
                    {
                        data = ds.Tables[0].Rows[0]["ReturnMessage"].ToString();
                        data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                    }
                    else
                    {
                        data = ConstantMessages.WebServiceLog.GenericErrorMsg;
                        data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult GetQuestionAnswer(JObject requestParams)
        {
            var       data    = string.Empty;
            ContentBO content = new ContentBO();

            try
            {
                var identity = MyAuthorizationServerProvider.AuthenticateUser();
                if (identity != null)
                {
                    if (!string.IsNullOrEmpty(Convert.ToString(requestParams["QuestionID"])))
                    {
                        int    CompID     = identity.CompId;
                        string UserID     = identity.UserID;
                        int    QuestionID = Convert.ToInt32(requestParams["QuestionID"]);

                        var ds = ContentBL.GetQuestionAnswer(Convert.ToInt32(ConstantMessages.Action.VIEW), CompID, QuestionID, UserID);
                        if (ds != null)
                        {
                            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                data = Utility.ConvertDataSetToJSONString(ds);
                                data = Utility.Successful(data);
                            }
                            else
                            {
                                data = ConstantMessages.WebServiceLog.GenericErrorMsg;
                                data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                            }
                        }
                        else
                        {
                            data = ConstantMessages.WebServiceLog.GenericErrorMsg;
                            data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                        }
                    }
                    else
                    {
                        data = ConstantMessages.WebServiceLog.InValidValues;
                        data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                    }
                }
                else
                {
                    data = Utility.AuthenticationError();
                    data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                }
            }
            catch (Exception ex)
            {
                data = ex.Message;
                data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
            }
            return(new APIResult(Request, data));
        }
Ejemplo n.º 5
0
        public IHttpActionResult ManageFlashcardIntro(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    var compId = identity.CompId;
                    var userId = identity.UserID;
                    var introId = 0; var comments = "";
                    var contentId = Convert.ToInt32(Convert.ToString(requestParams["ContentID"]));
                    var action    = Convert.ToInt32(Convert.ToString(requestParams["Action"]));
                    if (!string.IsNullOrEmpty(Convert.ToString(requestParams["ID"])))
                    {
                        introId = Convert.ToInt32(requestParams["ID"]);
                    }
                    comments = Convert.ToString(requestParams["Description"]);
                    var Title = Convert.ToString(requestParams["Title"]);
                    // CALL BL
                    var ds = QuizBL.ManageFlashcardIntro(compId, userId, 1, introId, "", comments, contentId, action);
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["StatusCode"].ToString() == "1")
                        {
                            // Successful
                            data = Utility.Successful("");
                        }
                        else
                        {
                            // Error. Check Logs
                            data = Utility.API_Status("1", "There might be some error. Please try again later");
                        }
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("1", "Unknown Error");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult CreateAdminUser(JObject jsonResult)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                string Message = string.Empty;
                UserBO objUser = new UserBO();

                if (identity.Role == ConstantMessages.Roles.superadmin)//identity.Role == ConstantMessages.Roles.companyadmin ||
                {
                    if (ValidateUserDetails(identity.Role, identity.CompId, jsonResult, out Message, out objUser, "create", Convert.ToInt32(identity.UserID)))
                    {
                        objUser.UserID = identity.UserID;
                        objUser.CompId = identity.CompId;
                        objUser.Role   = identity.Role;

                        var ds = OrganizationBL.CreateUpdateAdminUser(objUser, 1, 0);
                        if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["ReturnCode"].ToString() == "1")
                        {
                            data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                            data = Utility.Successful(data);

                            EmailHelper.GetEmailContent(Convert.ToInt32(ds.Tables[0].Rows[0]["InsertedID"]), 0, EmailHelper.Functionality.CREATE_ORG, "", "");
                        }
                        else if (ds.Tables[0].Rows.Count > 0)
                        {
                            data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                            data = Utility.Failed(data);
                        }
                        else
                        {
                            data = Utility.API_Status("0", "No data found");
                        }
                    }
                    else
                    {
                        data = Utility.API_Status("2", Message);
                    }
                }
                else
                {
                    data = Utility.API_Status("3", "You do not have access for this functionality");
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult SubmitAnswers(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    int    compId    = identity.CompId;
                    string userId    = identity.UserID;
                    int    topicId   = Convert.ToInt32(requestParams["TopicID"].ToString());
                    int    surveyId  = Convert.ToInt32(requestParams["SurveyID"].ToString());
                    int    moduleId  = Convert.ToInt32(requestParams["ModuleID"].ToString());
                    int    contentId = Convert.ToInt32(requestParams["ContentID"].ToString());
                    var    ds        = TrainningBL.SubmitAnswers(compId, userId, surveyId, requestParams);
                    if (ds.Tables.Count > 0)
                    {
                        if (Convert.ToInt32(ds.Tables[0].Rows[0]["ResponseID"].ToString()) > 0)
                        {
                            List <Question> questionList = new List <Question>();
                            var             dsContent    = TrainningBL.GetContentDetails(compId, userId, topicId, moduleId, contentId, ref questionList);
                            var             questionJson = JsonConvert.SerializeObject(questionList);
                            var             contents     = Utility.ConvertDataSetToJSONString(dsContent.Tables[0]);
                            contents = contents.Substring(2, contents.Length - 4);
                            data     = Utility.GetJSONData("1", "Successful", contents, questionJson,
                                                           Utility.ConvertDataSetToJSONString(dsContent.Tables[3]), Utility.ConvertDataSetToJSONString(dsContent.Tables[4]));
                        }
                        else
                        {
                            // Error. Check Logs
                            data = Utility.API_Status("1", "There might be some error. Please try again later");
                        }
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("1", "Unknown Error");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult GetAdminUserDetailsForParent(JObject jsonResult)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                string Message = string.Empty;
                UserBO objUser = new UserBO();

                int ChildUserID = 0;
                if (identity.Role == ConstantMessages.Roles.superadmin)
                {
                    objUser.UserID = identity.UserID;
                    objUser.CompId = identity.CompId;
                    objUser.Role   = identity.Role;

                    if (jsonResult.SelectToken("UserID") != null && jsonResult.SelectToken("UserID").ToString().Trim() != "")
                    {
                        ChildUserID = (int)jsonResult.SelectToken("UserID");

                        var ds = OrganizationBL.GetAdminUserDetails(objUser, ChildUserID);
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                            data = Utility.Successful(data);
                        }
                        else
                        {
                            data = Utility.API_Status("0", "No data found");
                        }
                    }
                    else
                    {
                        data = Utility.API_Status("2", "Please provide UserID");
                    }
                }
                else
                {
                    data = Utility.API_Status("3", "You do not have access for this functionality");
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
Ejemplo n.º 9
0
        public IHttpActionResult DeleteContent(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    var compId = identity.CompId;
                    var userId = identity.UserID;

                    ContentBO content = new ContentBO();
                    content.CompID    = identity.CompId;
                    content.CreatedBy = identity.UserID;
                    content.ContentID = Convert.ToInt32(requestParams["ContentID"]);
                    var ds = ContentBL.DeleteContent(content);
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["StatusCode"].ToString() == "1")
                        {
                            // Successful
                            data = Utility.Successful("");
                        }
                        else
                        {
                            // Error. Check Logs
                            data = Utility.API_Status("1", "There might be some error. Please try again later");
                        }
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("1", "Unknown Error");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult GetCountry(JObject requestParams)
        {
            var data = "";
            var ds   = OrganizationBL.GetCountry(0);

            if (ds.Tables.Count > 0)
            {
                data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                data = Utility.Successful(data);
            }
            else
            {
                data = Utility.API_Status("2", "No data found");
            }

            return(new APIResult(Request, data));
        }
        public IHttpActionResult RateContent(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    int    compId    = identity.CompId;
                    string userId    = identity.UserID;
                    int    topicId   = Convert.ToInt32(requestParams["TopicID"].ToString());
                    int    moduleId  = Convert.ToInt32(requestParams["ModuleID"].ToString());
                    int    contentId = Convert.ToInt32(requestParams["ContentID"].ToString());
                    string rating    = requestParams["Rating"].ToString();
                    var    ds        = TrainningBL.RateContent(compId, userId, topicId, moduleId, contentId, rating, userId);
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["StatusCode"].ToString() == "1")
                        {
                            // Successful
                            data = Utility.Successful("");
                        }
                        else
                        {
                            // Error. Check Logs
                            data = Utility.API_Status("1", "There might be some error. Please try again later");
                        }
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("1", "Unknown Error");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult GetContentDetails(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    int    compId    = identity.CompId;
                    string userId    = identity.UserID;
                    int    topicId   = Convert.ToInt32(requestParams["TopicID"].ToString());
                    int    moduleId  = Convert.ToInt32(requestParams["ModuleID"].ToString());
                    int    contentId = Convert.ToInt32(requestParams["ContentID"].ToString());

                    List <Question> questionList = new List <Question>();
                    var             ds           = TrainningBL.GetContentDetails(compId, userId, topicId, moduleId, contentId, ref questionList);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        var questionJson = JsonConvert.SerializeObject(questionList);
                        var contents     = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                        if (contents != "[]")
                        {
                            contents = contents.Substring(2, contents.Length - 4);
                        }
                        data = Utility.GetJSONData("1", "Successful", contents, questionJson,
                                                   Utility.ConvertDataSetToJSONString(ds.Tables[3]), Utility.ConvertDataSetToJSONString(ds.Tables[4]));
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("0", "No Records Found.");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult ViewAchievement(JObject requestParams)
        {
            var data = string.Empty;
            int CompID;
            int AchievementID = 0;

            try
            {
                var identity = MyAuthorizationServerProvider.AuthenticateUser();
                if (identity != null)
                {
                    CompID = identity.CompId;
                    if (!string.IsNullOrEmpty(requestParams["AchievementID"].ToString()))
                    {
                        AchievementID = (int)requestParams["AchievementID"];
                    }

                    var ds = AchivementBL.GetAchievements(CompID, AchievementID);
                    if (ds.Tables.Count > 0)
                    {
                        DataTable dt = ds.Tables["Data"];

                        data = Utility.ConvertDataSetToJSONString(dt);
                        data = Utility.Successful(data);
                    }
                    else
                    {
                        data = ConstantMessages.WebServiceLog.GenericErrorMsg;
                        data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                    }
                }
                else
                {
                    data = Utility.AuthenticationError();
                    data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                }
            }
            catch (Exception ex)
            {
                data = ex.Message;
                data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult RetakeTest(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    int    compId   = identity.CompId;
                    string userId   = identity.UserID;
                    string surveyId = requestParams["SurveyID"].ToString();
                    var    ds       = TrainningBL.ClearAnswers(compId, userId, surveyId);
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["StatusCode"].ToString() == "1")
                        {
                            // Successful
                            data = Utility.Successful("");
                        }
                        else
                        {
                            // Error. Check Logs
                            data = Utility.API_Status("1", "There might be some error. Please try again later");
                        }
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("0", "No Records Found.");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult GetAdminUserDetails(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                string Message = string.Empty;
                UserBO objUser = new UserBO();

                int ChildUserID = 0;
                if (identity.Role == ConstantMessages.Roles.companyadmin)
                {
                    objUser.UserID = identity.UserID;
                    objUser.CompId = identity.CompId;
                    objUser.Role   = identity.Role;

                    ChildUserID = Convert.ToInt32(identity.UserID);
                    var ds = OrganizationBL.GetAdminUserDetails(objUser, ChildUserID);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                        data = Utility.Successful(data);
                    }
                    else
                    {
                        data = Utility.API_Status("0", "No data found");
                    }
                }
                else
                {
                    data = Utility.API_Status("3", "You do not have access for this functionality");
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult GetAdminUsers()
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                UserBO objUser = new UserBO();

                if (identity.Role == ConstantMessages.Roles.companyadmin || identity.Role == ConstantMessages.Roles.superadmin)
                {
                    objUser.UserID = identity.UserID;
                    objUser.CompId = identity.CompId;
                    objUser.Role   = identity.Role;

                    var ds = OrganizationBL.GetAdminUsers(objUser);
                    if (ds.Tables.Count > 0)
                    {
                        data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                        data = Utility.Successful(data);
                    }
                    else
                    {
                        data = Utility.API_Status("2", "No user found");
                    }
                }
                else
                {
                    data = Utility.API_Status("3", "You do not have access for this functionality");
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult BindRole(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                var ds = OrganizationBL.GetRole(identity.Role, identity.RoleID);
                if (ds.Tables.Count > 0)
                {
                    data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                    data = Utility.Successful(data);
                }
                else
                {
                    data = Utility.API_Status("2", "No data found");
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
Ejemplo n.º 18
0
        public IHttpActionResult SaveContent(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    ContentBO content = new ContentBO();
                    content.CompID    = identity.CompId;
                    content.CreatedBy = identity.UserID;
                    content.TopicID   = Convert.ToInt32(Convert.ToString(requestParams["TopicID"]));
                    content.ModuleID  = Convert.ToInt32(Convert.ToString(requestParams["ModuleID"]));
                    content.ContentID = 0;
                    if (!string.IsNullOrEmpty(Convert.ToString(requestParams["ContentID"])))
                    {
                        content.ContentID = Convert.ToInt32(requestParams["ContentID"]);
                    }
                    content.ContentTypeID      = Convert.ToInt32(Convert.ToString(requestParams["ContentTypeID"]));
                    content.ContentTitle       = Convert.ToString(requestParams["Title"]);
                    content.ContentDescription = Convert.ToString(requestParams["Description"]);
                    content.FlashcardTitle     = Convert.ToString(requestParams["IntroTitle"]);
                    content.IsPublished        = Convert.ToBoolean(Convert.ToString(requestParams["IsPublished"]));
                    content.SkipFlashcard      = Convert.ToBoolean(Convert.ToString(requestParams["SkipFlashcard"]));
                    content.IsActive           = true;
                    content.IsGift             = Convert.ToBoolean(Convert.ToString(requestParams["IsGift"]));
                    var totalScore     = 0.0;
                    var passingScore   = 0.0;
                    var passingPercent = 0.0;
                    var docType        = "";
                    if (content.ContentTypeID == 2)
                    {
                        // Survey
                        docType = "SURVEY";
                    }
                    else if (content.ContentTypeID == 3)
                    {
                        // Flashcards
                        docType = "FLASHCARD";
                    }
                    else if (content.ContentTypeID == 5)
                    {
                        // Final Quiz
                        docType        = "FINALQUIZ";
                        totalScore     = Convert.ToDouble(Convert.ToString(requestParams["TotalScore"]));
                        passingScore   = Convert.ToDouble(Convert.ToString(requestParams["PassingScore"]));
                        passingPercent = Convert.ToDouble(Convert.ToString(requestParams["PassingPercentage"]));
                    }
                    content.TotalScore          = totalScore;
                    content.PassingScore        = passingScore;
                    content.PassingPercent      = passingPercent;
                    content.DocType             = docType;
                    content.ContentFileID       = null;
                    content.FlashcardHighlights = null;

                    var ds = new DataSet();
                    if (content.ContentID > 0)
                    {
                        ds = ContentBL.ModifyContent(content);
                    }
                    else
                    {
                        ds = ContentBL.CreateContent(content);
                    }
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["StatusCode"].ToString() == "1")
                        {
                            // Successful
                            data = Utility.Successful("");
                        }
                        else
                        {
                            // Error. Check Logs
                            data = Utility.API_Status("1", "There might be some error. Please try again later");
                        }
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("1", "Unknown Error");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
Ejemplo n.º 19
0
        public IHttpActionResult ManageAnsOptions(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    var compId = identity.CompId;
                    var userId = identity.UserID;
                    var answerId = 0; var title = ""; var isCorrect = false; var score = 0.0;

                    var action        = Convert.ToInt32(Convert.ToString(requestParams["Action"]));
                    var contentTypeId = Convert.ToInt32(Convert.ToString(requestParams["ContentTypeID"]));
                    var contentId     = Convert.ToInt32(requestParams["ContentID"]);
                    var questionId    = Convert.ToInt32(requestParams["QuestionID"]);
                    if (!string.IsNullOrEmpty(Convert.ToString(requestParams["AnswerID"])))
                    {
                        answerId = Convert.ToInt32(requestParams["AnswerID"]);
                    }
                    if (action == 1 || action == 2)
                    {
                        title     = Convert.ToString(requestParams["Title"]);
                        isCorrect = false;
                        if (!string.IsNullOrEmpty(Convert.ToString(requestParams["IsCorrect"])))
                        {
                            isCorrect = Convert.ToBoolean(Convert.ToString(requestParams["IsCorrect"]));
                        }
                        if (contentTypeId == 5)
                        {
                            // Final Quiz
                            score = Convert.ToDouble(Convert.ToString(requestParams["Score"])); // Numeric
                        }
                    }
                    else if (action == 3)
                    {
                    }
                    else if (action == 4)
                    {
                    }

                    // CALL BL
                    var ds = QuizBL.ManageAnsOptions(compId, userId, contentId, questionId, answerId, title, isCorrect, score, action);
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["StatusCode"].ToString() == "1")
                        {
                            // Successful
                            data = Utility.Successful("");
                        }
                        else
                        {
                            // Error. Check Logs
                            data = Utility.API_Status("1", "There might be some error. Please try again later");
                        }
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("1", "Unknown Error");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
Ejemplo n.º 20
0
        public IHttpActionResult ManageQuestion(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    var compId = identity.CompId;
                    var userId = identity.UserID;
                    var questionId = 0; var isMandatory = true; var isMultiline = true;
                    var contentId = 0; var title = ""; var qType = 0; var maxScore = 0.0;
                    var isBox         = false;
                    var contentTypeId = Convert.ToInt32(Convert.ToString(requestParams["ContentTypeID"]));
                    var action        = Convert.ToInt32(Convert.ToString(requestParams["Action"]));
                    var type          = Convert.ToInt32(Convert.ToString(requestParams["Type"]));
                    if (!string.IsNullOrEmpty(Convert.ToString(requestParams["QuestionID"])))
                    {
                        questionId = Convert.ToInt32(requestParams["QuestionID"]);
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString(requestParams["ContentID"])))
                    {
                        contentId = Convert.ToInt32(requestParams["ContentID"]);
                    }
                    if (action == 1 || action == 2)
                    {
                        title = Convert.ToString(requestParams["Title"]);
                        qType = Convert.ToInt32(Convert.ToString(requestParams["QType"])); // Numeric
                        if (!string.IsNullOrEmpty(Convert.ToString(requestParams["IsBox"])))
                        {
                            isBox = Convert.ToBoolean(Convert.ToString(requestParams["IsBox"]));
                        }

                        if (type == 1)
                        {
                            // Survey
                        }
                        else if (type == 2)
                        {
                            // Flashcards
                        }
                        else if (type == 3)
                        {
                            // Final Quiz
                            maxScore = Convert.ToDouble(Convert.ToString(requestParams["MaxScore"]));
                        }
                    }
                    else if (action == 3)
                    {
                    }
                    else if (action == 4)
                    {
                    }

                    // CALL BL
                    var ds = QuizBL.ManageQuestion(compId, userId, questionId, contentId, isMandatory, isMultiline, title, qType, isBox, action);
                    if (Convert.ToInt32(ds.Tables[0].Rows[0]["QuestionID"].ToString()) > 0 && (action == 1 || action == 2))
                    {
                        questionId = Convert.ToInt32(ds.Tables[0].Rows[0]["QuestionID"].ToString());
                        for (int i = 0; i < requestParams["AnswerOptions"].Count(); i++)
                        {
                            bool   isCorrect = false;
                            double score     = 0;
                            var    answerid  = 0;
                            if (!string.IsNullOrEmpty(Convert.ToString(requestParams["AnswerOptions"][i]["CorrectScore"])))
                            {
                                score = Convert.ToInt32(requestParams["AnswerOptions"][i]["CorrectScore"]);
                            }
                            if (!string.IsNullOrEmpty(Convert.ToString(requestParams["AnswerOptions"][i]["AnswerID"])))
                            {
                                answerid = Convert.ToInt32(requestParams["AnswerOptions"][i]["AnswerID"]);
                            }
                            if (!string.IsNullOrEmpty(Convert.ToString(requestParams["AnswerOptions"][i]["IsCorrect"])))
                            {
                                isCorrect = Convert.ToBoolean(Convert.ToString(requestParams["AnswerOptions"][i]["IsCorrect"]));
                            }
                            var ds1 = QuizBL.ManageAnsOptions(compId, userId, contentId, questionId, answerid, Convert.ToString(requestParams["AnswerOptions"][i]["AnswerText"]),
                                                              isCorrect, score, answerid > 0 ? 2 : 1);
                        }
                    }

                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["StatusCode"].ToString() == "1")
                        {
                            // Successful
                            data = Utility.Successful("");
                        }
                        else
                        {
                            // Error. Check Logs
                            data = Utility.API_Status("1", "There might be some error. Please try again later");
                        }
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("1", "Unknown Error");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
Ejemplo n.º 21
0
        public IHttpActionResult AddFavAndBookMark(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    int  TopicID    = 0;
                    int  IsFav      = 0;
                    int  IsBookMark = 0;
                    bool ValFlag    = true;

                    string Message = string.Empty;
                    int    compId  = identity.CompId;
                    string userId  = identity.UserID;

                    if (requestParams.SelectToken("TopicID") != null && requestParams.SelectToken("TopicID").ToString().Trim() != "")
                    {
                        TopicID = Convert.ToInt32(requestParams.SelectToken("TopicID"));
                    }
                    else
                    {
                        Message = "Please provide TopicID."; ValFlag = false;
                    }
                    if (requestParams.SelectToken("Fav") != null && requestParams.SelectToken("Fav").ToString().Trim() != "" &&
                        (requestParams.SelectToken("Fav").ToString().Trim() == "0" || requestParams.SelectToken("Fav").ToString().Trim() == "1"))
                    {
                        IsFav = Convert.ToInt32(requestParams.SelectToken("Fav"));
                    }
                    else
                    {
                        Message = "Please provide valid Favourite flag."; ValFlag = false;
                    }
                    if (requestParams.SelectToken("BookMark") != null && requestParams.SelectToken("BookMark").ToString().Trim() != "" &&
                        (requestParams.SelectToken("BookMark").ToString().Trim() == "0" || requestParams.SelectToken("BookMark").ToString().Trim() == "1"))
                    {
                        IsBookMark = Convert.ToInt32(requestParams.SelectToken("BookMark"));
                    }
                    else
                    {
                        Message = "Please provide valid Bookmark flag."; ValFlag = false;
                    }

                    if (ValFlag)
                    {
                        var ds = TrainningBL.AddFavAndBookMark(userId, compId, TopicID, IsFav, IsBookMark);
                        data = Utility.ConvertDataSetToJSONString(ds.Tables[0]);
                        data = Utility.Successful(data);
                    }
                    else
                    {
                        data = Utility.API_Status("2", Message);
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
Ejemplo n.º 22
0
        public IHttpActionResult ModuleAllAction(JObject requestParams)
        {
            var    data = string.Empty;
            int    Action;
            int    TopicID;
            int    ModuleID;
            int    CompId;
            string SrNo          = string.Empty;
            string Title         = string.Empty;
            string Overview      = string.Empty;
            string Description   = string.Empty;
            string CreatedBy     = string.Empty;
            string IsPublished   = string.Empty;
            string SkipFlashcard = string.Empty;

            try
            {
                var identity = MyAuthorizationServerProvider.AuthenticateUser();
                if (identity != null)
                {
                    if ((Convert.ToInt32(requestParams["Action"]) != 4 && Convert.ToInt32(requestParams["TopicID"]) != 0 && !string.IsNullOrEmpty(requestParams["Title"].ToString()) && !string.IsNullOrEmpty(requestParams["Overview"].ToString()) && !string.IsNullOrEmpty(requestParams["Description"].ToString())))
                    {
                        CompId      = identity.CompId;
                        CreatedBy   = identity.UserID;
                        Action      = Convert.ToInt32(requestParams["Action"]);
                        TopicID     = Convert.ToInt32(requestParams["TopicID"]);
                        ModuleID    = Convert.ToInt32(requestParams["ModuleID"]);
                        SrNo        = requestParams["SrNo"].ToString();
                        Overview    = requestParams["Overview"].ToString();
                        Title       = requestParams["Title"].ToString();
                        Description = requestParams["Description"].ToString();
                        IsPublished = requestParams["IsPublished"].ToString();
                        var ds = ModulesBL.ModulesAllAction(Action, ModuleID, TopicID, CompId, Title, Overview, Description, SrNo, IsPublished, SkipFlashcard, CreatedBy);
                        if (ds.Tables.Count > 0)
                        {
                            DataTable dt = ds.Tables["Data"];
                            if (dt.Rows[0]["ReturnCode"].ToString() == "1")
                            {
                                data = Utility.ConvertDataSetToJSONString(dt);
                                data = Utility.Successful(data);
                            }
                            else
                            {
                                data = ConstantMessages.WebServiceLog.GenericErrorMsg;
                                data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                            }
                        }
                        else
                        {
                            data = ConstantMessages.WebServiceLog.GenericErrorMsg;
                            data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                        }
                    }
                    else if (Convert.ToInt32(requestParams["Action"]) == 4)
                    {
                        CompId      = identity.CompId;
                        CreatedBy   = identity.UserID;
                        Action      = Convert.ToInt32(requestParams["Action"]);
                        TopicID     = Convert.ToInt32(requestParams["TopicID"]);
                        ModuleID    = Convert.ToInt32(requestParams["ModuleID"]);
                        IsPublished = requestParams["IsPublished"].ToString();
                        var ds = ModulesBL.ModulesAllAction(Action, ModuleID, TopicID, CompId, Title, Overview, Description, SrNo, IsPublished, SkipFlashcard, CreatedBy);
                        if (ds.Tables.Count > 0)
                        {
                            DataTable dt = ds.Tables["Data1"];
                            if (dt.Rows[0]["ReturnCode"].ToString() == "1")
                            {
                                DataTable _dt = ds.Tables["Data"];
                                data = Utility.ConvertDataSetToJSONString(_dt);
                                data = Utility.Successful(data);
                            }
                            else
                            {
                                data = ConstantMessages.WebServiceLog.GenericErrorMsg;
                                data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                            }
                        }
                        else
                        {
                            data = ConstantMessages.WebServiceLog.GenericErrorMsg;
                            data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                        }
                    }

                    else
                    {
                        data = ConstantMessages.WebServiceLog.InValidValues;
                        data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                    }
                }
                else
                {
                    data = Utility.AuthenticationError();
                    data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                }
            }
            catch (Exception ex)
            {
                data = ex.Message;
                data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult AssignTopicsByEntity(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    int compId = identity.CompId;
                    //string[] mailUserIDs = new string[] { };
                    List <string> mailUserIDs = new List <string>();
                    string        userId      = identity.UserID;
                    var           topicIds    = Convert.ToString(requestParams["TopicIds"].ToString());
                    var           groupIds    = Convert.ToString(requestParams["GroupIds"].ToString());
                    var           userIds     = Convert.ToString(requestParams["UserIds"].ToString());
                    var           removeTopic = Convert.ToString(requestParams["RemoveTopics"].ToString());

                    if (!string.IsNullOrEmpty(userIds))
                    {
                        var dsTopics = TrainningBL.GetUserAssignedTopic(compId, userIds);

                        string[] arrTopics = topicIds.Split(',');
                        string[] arrUsers  = userIds.Split(',');

                        //mailUserIDs = new string[arrUsers.Length];

                        if (dsTopics.Tables.Count > 0 && dsTopics.Tables[0].Rows.Count > 0)
                        {
                            for (int j = 0; j < arrUsers.Length; j++)
                            {
                                for (int i = 0; i < arrTopics.Length; i++)
                                {
                                    if (!dsTopics.Tables[0].Select().ToList().Exists(row => row["Topics"].ToString() == arrTopics[i] && row["UserID"].ToString() == arrUsers[j]))
                                    {
                                        mailUserIDs.Add(arrUsers[j]);
                                    }
                                }
                            }
                        }
                    }

                    var ds = TrainningBL.AssignTopicsByEntity(compId, userId, topicIds, groupIds, userIds, removeTopic);
                    if (ds.Tables.Count > 0)
                    {
                        // Successful
                        data = Utility.Successful("");
                        if (mailUserIDs.Count() > 0)
                        {
                            mailUserIDs = mailUserIDs.Distinct().ToList();
                            foreach (string UserID in mailUserIDs)
                            {
                                EmailHelper.GetEmailContent(Convert.ToInt32(UserID), identity.CompId, EmailHelper.Functionality.ADD_TOPIC, "", "");
                            }
                        }
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("1", "Unknown Error");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult UpdateContent(JObject requestParams)
        {
            var data     = "";
            var identity = MyAuthorizationServerProvider.AuthenticateUser();

            if (identity != null)
            {
                try
                {
                    int    compId    = identity.CompId;
                    string userId    = identity.UserID;
                    int    topicId   = Convert.ToInt32(requestParams["TopicID"].ToString());
                    int    moduleId  = Convert.ToInt32(requestParams["ModuleID"].ToString());
                    int    contentId = Convert.ToInt32(requestParams["ContentID"].ToString());
                    var    ds        = TrainningBL.UpdateContent(compId, userId, topicId, moduleId, contentId);
                    if (ds.Tables.Count > 0)
                    {
                        var    tableIndex = 0;
                        string isGift     = "0";
                        if (ds.Tables[0].Columns.Contains("IsGift"))
                        {
                            // Successful -  Unlocked a gift
                            isGift     = "1";
                            data       = Utility.ContentUpdated("1", "Success", isGift, Utility.ConvertDataSetToJSONString(ds.Tables[0]));
                            tableIndex = 1;
                            TrainningBL.SendNotification(compId, userId, ConstantMessages.NotificationType.gift, "", ds.Tables[0].Rows[0]["Title"].ToString());
                        }
                        else if (ds.Tables[0].Rows[0]["StatusCode"].ToString() == "1")
                        {
                            // Successful - Without Gift
                            data = Utility.ContentUpdated("1", "Success", isGift, "");
                        }
                        else
                        {
                            // Error. Check Logs
                            data = Utility.API_Status("1", "There might be some error. Please try again later");
                        }

                        if (ds.Tables[tableIndex].Columns.Contains("StatusCode"))
                        {
                            var moduleCompleted = false;
                            if (Convert.ToBoolean(Convert.ToInt32(Convert.ToString(ds.Tables[tableIndex].Rows[0]["IsModuleCompleted"]))))
                            {
                                // Module Completed
                                // ds.Tables[tableIndex + 1];
                                moduleCompleted = true;
                                TrainningBL.SendNotification(compId, userId, ConstantMessages.NotificationType.module, "", ds.Tables[tableIndex + 1].Rows[0]["Title"].ToString());
                            }
                            if (Convert.ToBoolean(Convert.ToInt32(Convert.ToString(ds.Tables[tableIndex].Rows[0]["IsTopicCompleted"]))))
                            {
                                // Topic Completed
                                //ds.Tables[tableIndex + 1 + (moduleCompleted ? 1 : 0)];
                                TrainningBL.SendNotification(compId, userId, ConstantMessages.NotificationType.topic, "", ds.Tables[tableIndex + 1 + (moduleCompleted ? 1 : 0)].Rows[0]["Title"].ToString());
                            }
                        }
                    }
                    else
                    {
                        // Unknown Error
                        data = Utility.API_Status("0", "No Records Found.");
                    }
                }
                catch (Exception ex)
                {
                    data = Utility.Exception(ex);;
                }
            }
            else
            {
                data = Utility.AuthenticationError();
            }
            return(new APIResult(Request, data));
        }
        public IHttpActionResult CreateAchievement(JObject requestParams)
        {
            var    data                  = string.Empty;
            string AchievementTitle      = string.Empty;
            string AchivementDescription = string.Empty;
            string LongDescription       = string.Empty;
            int    CompID;
            string CreatedBy = string.Empty;

            try
            {
                var identity = MyAuthorizationServerProvider.AuthenticateUser();
                if (identity != null)
                {
                    if (!string.IsNullOrEmpty(requestParams["AchievementTitle"].ToString()) && !string.IsNullOrEmpty(requestParams["AchivementDescription"].ToString()) &&
                        !string.IsNullOrEmpty(requestParams["LongDescription"].ToString()))
                    {
                        CompID    = identity.CompId;
                        CreatedBy = identity.UserID;


                        if (!string.IsNullOrEmpty(requestParams["AchievementTitle"].ToString()))
                        {
                            AchievementTitle = requestParams["AchievementTitle"].ToString();
                        }
                        else
                        {
                            AchievementTitle = string.Empty;
                        }
                        if (!string.IsNullOrEmpty(requestParams["AchivementDescription"].ToString()))
                        {
                            AchivementDescription = requestParams["AchivementDescription"].ToString();
                        }
                        else
                        {
                            AchivementDescription = string.Empty;
                        }
                        if (!string.IsNullOrEmpty(requestParams["LongDescription"].ToString()))
                        {
                            LongDescription = requestParams["LongDescription"].ToString();
                        }
                        else
                        {
                            LongDescription = string.Empty;
                        }
                        var ds = AchivementBL.CreateAchievement(CompID, 0, AchievementTitle, AchivementDescription, LongDescription, CreatedBy);

                        if (ds.Tables.Count > 0)
                        {
                            DataTable dt = ds.Tables["Data"];
                            if (dt.Rows[0]["ReturnCode"].ToString() == "1")
                            {
                                data = Utility.ConvertDataSetToJSONString(dt);
                                data = Utility.Successful(data);
                            }
                            else
                            {
                                data = ConstantMessages.WebServiceLog.GenericErrorMsg;
                                data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                            }
                        }
                        else
                        {
                            data = ConstantMessages.WebServiceLog.GenericErrorMsg;
                            data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                        }
                    }
                    else
                    {
                        data = ConstantMessages.WebServiceLog.InValidValues;
                        data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                    }
                }
                else
                {
                    data = Utility.AuthenticationError();
                    data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
                }
            }
            catch (Exception ex)
            {
                data = ex.Message;
                data = Utility.API_Status(Convert.ToInt32(ConstantMessages.StatusCode.Failure).ToString(), data);
            }
            return(new APIResult(Request, data));
        }