Beispiel #1
0
        public static Boolean InsertUpdateTP_Instructors(clsTP_Instructors objTP_Instructors)
        {
            bool   isAdded = false;
            string SpName  = "usp_InsertUpdateTP_Instructors";

            try
            {
                using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"]))
                {
                    db.Execute(SpName, objTP_Instructors, commandType: CommandType.StoredProcedure);
                }
                isAdded = true;
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorLogging(ex, false);
                ErrorHandler.ReadError();
            }
            return(isAdded);
        }
Beispiel #2
0
        public static clsTP_Instructors SelectTP_InstructorsById(int?TP_InstructorListId)
        {
            clsTP_Instructors objTP_Instructors = new clsTP_Instructors();
            bool   isnull = true;
            string SpName = "usp_SelectTP_Instructors";
            var    objPar = new DynamicParameters();

            if (String.IsNullOrEmpty(TP_InstructorListId.ToString()))
            {
                throw new ArgumentException("Function parameters cannot be blank!");
            }
            else
            {
                try
                {
                    objPar.Add("@TP_InstructorListId", TP_InstructorListId, dbType: DbType.Int32);

                    using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"]))
                    {
                        objTP_Instructors = db.Query <clsTP_Instructors>(SpName, objPar, commandType: CommandType.StoredProcedure).SingleOrDefault();
                        isnull            = false;
                    }
                }
                catch (Exception ex)
                {
                    ErrorHandler.ErrorLogging(ex, false);
                    ErrorHandler.ReadError();
                }
            }

            if (isnull)
            {
                return(null);
            }
            else
            {
                return(objTP_Instructors);
            }
        }