コード例 #1
0
        public ReturnResult <RecruitmentNewsModel> InsertRecruitmentNews(RecruitmentNewsModel recruitmentNews)
        {
            var        result       = new ReturnResult <RecruitmentNewsModel>();
            DbProvider db           = new DbProvider();
            string     outCode      = String.Empty;
            string     outMessage   = String.Empty;
            string     totalRecords = String.Empty;
            int        outNewId     = 0;

            try
            {
                // Set tên stored procedure
                db.SetQuery("Inside_RecruitmentNews_Insert", CommandType.StoredProcedure)
                .SetParameter("BranchId", SqlDbType.Int, recruitmentNews.BranchId)
                .SetParameter("JobCode", SqlDbType.NVarChar, recruitmentNews.JobCode)
                .SetParameter("AreaId", SqlDbType.Int, recruitmentNews.AreaId)
                .SetParameter("JobTypeId", SqlDbType.Int, recruitmentNews.JobTypeId)
                .SetParameter("Title", SqlDbType.NVarChar, recruitmentNews.Title)
                .SetParameter("NumberPositions", SqlDbType.SmallInt, recruitmentNews.NumberPositions)
                .SetParameter("JobPositionId", SqlDbType.Int, recruitmentNews.JobPositionId)
                .SetParameter("JobLevelId", SqlDbType.Int, recruitmentNews.JobLevelId)
                .SetParameter("MinSalary", SqlDbType.NVarChar, recruitmentNews.MinSalary)
                .SetParameter("MaxSalary", SqlDbType.NVarChar, recruitmentNews.MaxSalary)
                .SetParameter("CurrentUnit", SqlDbType.NVarChar, recruitmentNews.CurrentUnit)
                .SetParameter("ShowSalary", SqlDbType.TinyInt, recruitmentNews.ShowSalary)
                .SetParameter("JobDescription", SqlDbType.NVarChar, recruitmentNews.JobDescription)
                .SetParameter("JobRequirement", SqlDbType.NVarChar, recruitmentNews.JobRequirement)
                .SetParameter("JobFullDescription", SqlDbType.NVarChar, recruitmentNews.JobFullDescription)
                .SetParameter("JobRequest", SqlDbType.NVarChar, recruitmentNews.JobRequest)
                .SetParameter("JobBenefit", SqlDbType.NVarChar, recruitmentNews.JobBenefit)
                .SetParameter("JobInfomation", SqlDbType.NVarChar, recruitmentNews.JobInfomation)
                .SetParameter("company_name", SqlDbType.NVarChar, recruitmentNews.company_name)
                .SetParameter("company_info", SqlDbType.NVarChar, recruitmentNews.company_info)
                .SetParameter("company_logo", SqlDbType.NVarChar, recruitmentNews.company_logo)
                .SetParameter("company_size", SqlDbType.NVarChar, recruitmentNews.company_size)
                .SetParameter("JobType", SqlDbType.TinyInt, recruitmentNews.JobType)
                .SetParameter("Gender", SqlDbType.TinyInt, recruitmentNews.Gender)
                .SetParameter("AgeFrom", SqlDbType.TinyInt, recruitmentNews.AgeFrom)
                .SetParameter("AgeTo", SqlDbType.TinyInt, recruitmentNews.AgeTo)
                .SetParameter("ExamType", SqlDbType.TinyInt, recruitmentNews.ExamType)
                .SetParameter("StartDate", SqlDbType.DateTime, recruitmentNews.StartDate.ToString())
                .SetParameter("EndDate", SqlDbType.DateTime, recruitmentNews.EndDate.ToString())
                .SetParameter("Hot", SqlDbType.TinyInt, recruitmentNews.Hot)
                .SetParameter("ProcessStatus", SqlDbType.TinyInt, recruitmentNews.ProcessStatus)
                .SetParameter("CreatedUser", SqlDbType.NVarChar, recruitmentNews.CreatedUser)
                //.SetParameter("CreatedDate", SqlDbType.DateTime, recruitmentNews.CreatedDate)
                .SetParameter("YearExpMax", SqlDbType.SmallInt, recruitmentNews.YearExpMax)
                .SetParameter("YearExpMin", SqlDbType.SmallInt, recruitmentNews.YearExpMin)
                .SetParameter("FK_VacancyId", SqlDbType.Int, recruitmentNews.FK_VacancyId)
                //.SetParameter("FullTitle", SqlDbType.NVarChar, recruitmentNews.FullTitle)
                .SetParameter("BranchAddressId", SqlDbType.Int, recruitmentNews.BranchAddressId)
                .SetParameter("SkillId", SqlDbType.Int, recruitmentNews.SkillId)
                .SetParameter("JobCategoryId", SqlDbType.Int, recruitmentNews.JobCategoryId)
                // Output parameter
                .SetParameter("OUT_NewId", SqlDbType.Int, DBNull.Value, ParameterDirection.Output)
                .SetParameter("OUT_ErrorCode", SqlDbType.NVarChar, DBNull.Value, 255, ParameterDirection.Output)
                .SetParameter("OUT_ReturnMessage", SqlDbType.NVarChar, DBNull.Value, 255, ParameterDirection.Output)

                // Xử lý thủ tục và kết quả trả về từ DB
                .ExcuteNonQuery()
                .Complete();
                // Xử lý Logs

                db.GetOutValue("OUT_ErrorCode", out outCode)
                .GetOutValue("OUT_ReturnMessage", out outMessage)
                .GetOutValue("OUT_NewId", out outNewId);
                if (outCode != "0" || outCode == "")
                {
                    result.Failed(outCode, outMessage);
                }
                else
                {
                    recruitmentNews.RecruitmentId = outNewId;
                    result.Item = recruitmentNews;
                }
                return(result);
            }
            catch (Exception ex)
            {
                result.Failed("-1", ex.Message);
            }
            return(result);
        }