Exemplo n.º 1
0
        /// <summary>
        /// Used to save skills & subskills created using Improve Skills option
        /// </summary>
        /// <param name="argLoggedInUser">Logged in user</param>
        /// <param name="argImproveSkills">Skill and Subskill details</param>
        /// <returns></returns>
        public void ImproveSkills(ImproveSkillsBE argImproveSkills, string argLoggedInUser)
        {
            #region Declarations
            SkillsDBManager         l_SkillsDBManager = new SkillsDBManager("SkillsDBConnection");
            List <IDbDataParameter> l_Parameters      = new List <IDbDataParameter>();
            XElement l_skillXML = null;
            int      l_LastID   = 0;
            #endregion
            try
            {
                if (argLoggedInUser != null && argImproveSkills != null && argImproveSkills.UserSubskills != null && argImproveSkills.UserSubskills.Count > 0)
                {
                    //Generate XML
                    l_skillXML = GenerateSkillXML(argImproveSkills.UserSubskills);

                    //Create Parameters
                    l_Parameters.Add(l_SkillsDBManager.CreateParameter(ProcedureParams.LOGGEDINUSERID, argLoggedInUser, DbType.String));
                    l_Parameters.Add(l_SkillsDBManager.CreateParameter(ProcedureParams.COMMENTS, argImproveSkills.Comments, DbType.String));
                    l_Parameters.Add(l_SkillsDBManager.CreateParameter(ProcedureParams.SKILLXML, l_skillXML.ToString(), DbType.Xml));
                    l_Parameters.Add(l_SkillsDBManager.CreateParameter(ProcedureParams.TYPE, argImproveSkills.Mode, DbType.String));

                    if (string.IsNullOrEmpty(argImproveSkills.FileUploadGUID))
                    {
                        l_Parameters.Add(l_SkillsDBManager.CreateParameter(ProcedureParams.FILEUPLOADGUID, DBNull.Value, DbType.String));
                    }
                    else
                    {
                        l_Parameters.Add(l_SkillsDBManager.CreateParameter(ProcedureParams.FILEUPLOADGUID, argImproveSkills.FileUploadGUID, DbType.String));
                    }

                    if (string.IsNullOrEmpty(argImproveSkills.FileUploadName))
                    {
                        l_Parameters.Add(l_SkillsDBManager.CreateParameter(ProcedureParams.FILEUPLOADNAME, DBNull.Value, DbType.String));
                    }
                    else
                    {
                        l_Parameters.Add(l_SkillsDBManager.CreateParameter(ProcedureParams.FILEUPLOADNAME, argImproveSkills.FileUploadName, DbType.String));
                    }


                    //Call stored procedure
                    l_SkillsDBManager.Insert(StoredProcedures.SAVE_IMPROVESKILLS, CommandType.StoredProcedure, l_Parameters.ToArray(), out l_LastID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult ImproveSkills(string argLoggedInUser, [FromBody] ImproveSkillsBE argImproveSkills)
        {
            #region Declarations
            SkillBLO l_SkillBLO = new SkillBLO();
            #endregion
            try
            {
                l_SkillBLO.ImproveSkills(argImproveSkills, argLoggedInUser);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Ok());
        }
        /// <summary>
        /// This function is used to convert model to Business Entity
        /// </summary>
        /// <param name="argImproveSkills"></param>
        /// <param name="argGUID"></param>
        /// <returns></returns>
        private ImproveSkillsBE ConvertImproveSkillRequestToBusinessEntity(ImproveSkills argImproveSkills, string argGUID)
        {
            #region Declarations
            ImproveSkillsBE      l_ImproveSkillsBE       = new ImproveSkillsBE();
            SubSkillBECollection l_SubskillsBECollection = new SubSkillBECollection();
            SubskillsBE          l_Subskills;
            #endregion
            try
            {
                if (argImproveSkills != null)
                {
                    //Comments
                    l_ImproveSkillsBE.Comments = argImproveSkills.Comments;

                    //File details
                    if (argImproveSkills.File != null)
                    {
                        l_ImproveSkillsBE.FileUploadName = argImproveSkills.File.FileName;
                        l_ImproveSkillsBE.FileUploadGUID = argGUID;
                    }

                    //Mode
                    l_ImproveSkillsBE.Mode = argImproveSkills.Mode;

                    //Subskills
                    if (argImproveSkills.SubskillCollection != null && argImproveSkills.SubskillCollection.Count > 0)
                    {
                        foreach (var subskills in argImproveSkills.SubskillCollection)
                        {
                            l_Subskills            = new SubskillsBE();
                            l_Subskills.SubSkillID = subskills.SubSkillID;
                            l_Subskills.SkillID    = subskills.SkillID;
                            l_SubskillsBECollection.Add(l_Subskills);
                        }
                        l_ImproveSkillsBE.UserSubskills = l_SubskillsBECollection;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(l_ImproveSkillsBE);
        }
        /// <summary>
        /// Save Initial skill requests to DB
        /// </summary>
        /// <param name="argSkillRequest"></param>
        /// <returns></returns>
        private async Task <HttpResponseMessage> ImproveSkillRequest(ImproveSkills argImproveSkills, string argGUID)
        {
            #region Declarations
            HttpResponseMessage l_Response        = new HttpResponseMessage();
            ImproveSkillsBE     l_ImproveSkillsBE = new ImproveSkillsBE();
            string l_SaveSkillURL = apiBaseURL + "/ImproveSkills?argLoggedInUser=" + GetLoggedInUserID();
            #endregion

            try
            {
                l_ImproveSkillsBE = ConvertImproveSkillRequestToBusinessEntity(argImproveSkills, argGUID);
                if (l_ImproveSkillsBE != null)
                {
                    l_Response = await client.PostAsJsonAsync(l_SaveSkillURL, l_ImproveSkillsBE);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(l_Response);
        }