/// <summary>
        /// Creates a new PermitRegistration record using async
        /// </summary>
        public static async Task<int> CreateAsync(PermitRegistrationDO DO)
        {
            SqlParameter _RegistrationID = new SqlParameter("RegistrationID", SqlDbType.Int);
            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
            SqlParameter _Read = new SqlParameter("Read", SqlDbType.Bit);
            SqlParameter _Edit = new SqlParameter("Edit", SqlDbType.Bit);
            SqlParameter _Coordinator = new SqlParameter("Coordinator", SqlDbType.Bit);
            
            _RegistrationID.Value = DO.RegistrationID;
            _PermitKey.Value = DO.PermitKey;
            _Read.Value = DO.Read;
            _Edit.Value = DO.Edit;
            _Coordinator.Value = DO.Coordinator;
            
            SqlParameter[] _params = new SqlParameter[] {
                _RegistrationID,
                _PermitKey,
                _Read,
                _Edit,
                _Coordinator
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            return await DataCommon.ExecuteScalarAsync("[dbo].[PermitRegistration_Insert]", _params, pid);
            
        }
Пример #2
0
        public ActionResult NewPermitRegistration(FormCollection data)
        {
            try
            {
                int RegistrationID = Convert.ToInt32(data["RegistrationID"]);
                int PermitKey = Convert.ToInt32( data["PermitKey"]);
                bool Read = Convert.ToBoolean(data["Read"]);
                bool Edit = Convert.ToBoolean(data["Edit"]);
                bool Coordinator = Convert.ToBoolean(data["Coordinator"]);

                PermitRegistrationDO record = new PermitRegistrationDO() { Coordinator = Coordinator, Edit = Edit, PermitKey = PermitKey, RegistrationID = RegistrationID, Read = Read };
                record.PermitRegistrationID = PermitRegistrationBLL.Save(record);
                AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.OK, "The user's permission was added");
                result.Data.Add("PermitRegistration", record);
                return Json(result);
            }
            catch (Exception ex)
            {
                AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.ERROR, ex.Message);
                return Json(result);
            }
        }
        /// <summary>
        /// Gets all PermitRegistration records
        /// </summary>
        public static async Task<PermitRegistrationDO[]> GetAllAsync()
        {

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[PermitRegistration_GetAll]", new SqlParameter[] { }, pid);
            
            List<PermitRegistrationDO> objs = new List<PermitRegistrationDO>();
            
            while(sr.Read()){

                PermitRegistrationDO obj = new PermitRegistrationDO();
                
                obj.PermitRegistrationID = sr.GetInt32(sr.GetOrdinal("PermitRegistrationID"));
                obj.RegistrationID = sr.GetInt32(sr.GetOrdinal("RegistrationID"));
                obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey"));
                obj.Read = sr.GetBoolean(sr.GetOrdinal("Read"));
                obj.Edit = sr.GetBoolean(sr.GetOrdinal("Edit"));
                obj.Coordinator = sr.GetBoolean(sr.GetOrdinal("Coordinator"));
                


                objs.Add(obj);
            }

            return objs.ToArray();
        }
        /// <summary>
        /// Selects PermitRegistration records by RegistrationIDPermitKey
        /// </summary>
        public static async Task<PermitRegistrationDO[]> GetByRegistrationIDPermitKeyAsync(Int32 RegistrationID,
 Int32 PermitKey)
        {

            SqlParameter _RegistrationID = new SqlParameter("RegistrationID", SqlDbType.Int);
            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
			
            _RegistrationID.Value = RegistrationID;
            _PermitKey.Value = PermitKey;
			
            SqlParameter[] _params = new SqlParameter[] {
                _RegistrationID,
                _PermitKey
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[PermitRegistration_GetByRegistrationIDPermitKey]", _params, pid);


            List<PermitRegistrationDO> objs = new List<PermitRegistrationDO>();
			
            while(sr.Read())
            {
                PermitRegistrationDO obj = new PermitRegistrationDO();
				
                obj.PermitRegistrationID = sr.GetInt32(sr.GetOrdinal("PermitRegistrationID"));
                obj.RegistrationID = sr.GetInt32(sr.GetOrdinal("RegistrationID"));
                obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey"));
                obj.Read = sr.GetBoolean(sr.GetOrdinal("Read"));
                obj.Edit = sr.GetBoolean(sr.GetOrdinal("Edit"));
                obj.Coordinator = sr.GetBoolean(sr.GetOrdinal("Coordinator"));
                

                objs.Add(obj);
            }

            return objs.ToArray();
        }
        /// <summary>
        /// Deletes a PermitRegistration record
        /// </summary>
        public static async Task<int> DeleteAsync(PermitRegistrationDO DO)
        {
            SqlParameter _PermitRegistrationID = new SqlParameter("PermitRegistrationID", SqlDbType.Int);
            
            _PermitRegistrationID.Value = DO.PermitRegistrationID;
            
            SqlParameter[] _params = new SqlParameter[] {
                _PermitRegistrationID
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            return await DataCommon.ExecuteScalarAsync("[dbo].[PermitRegistration_Delete]", _params, pid);
        }