コード例 #1
0
        public projectMasterModel master(scheduleCourseModel value)
        {
            projectMasterModel result = new projectMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    string sql = "select convert(nvarchar(4), MPJ_YEAR) code, convert(nvarchar(4), MPJ_YEAR) [text] ";
                    sql        += " from MAS_PROJECT ";
                    sql        += " where MPJ_YEAR is not null ";
                    sql        += " group by    MPJ_YEAR ";
                    result.year = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql            = "select		convert(nvarchar(5), MPJ_ID) code ";
                    sql           += " , MPJ_NAME [text] ";
                    sql           += " from MAS_PROJECT ";
                    sql           += " where MPJ_STATUS = 1 ";
                    sql           += " order by MPJ_NAME ";
                    result.project = context.Database.SqlQuery <dropdown>(sql).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(result);
        }
コード例 #2
0
        public projectMasterModel master(projectModel value)
        {
            projectMasterModel result = new projectMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    string sql = "select convert(nvarchar(4), MPJ_YEAR) code, convert(nvarchar(4), MPJ_YEAR) [text] ";
                    sql        += " from MAS_PROJECT ";
                    sql        += " where MPJ_YEAR is not null ";
                    sql        += " group by    MPJ_YEAR ";
                    result.year = context.Database.SqlQuery <dropdown>(sql).ToList();

                    sql            = "select		convert(nvarchar(5), MPJ_ID) code ";
                    sql           += " , MPJ_NAME [text] ";
                    sql           += " from MAS_PROJECT ";
                    sql           += " where MPJ_STATUS = 1 ";
                    sql           += " order by MPJ_NAME ";
                    result.project = context.Database.SqlQuery <dropdown>(sql).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(result);
        }