Пример #1
0
        /// <summary>
        /// This function will return a list of all the Group saved in the system database
        /// </summary>
        /// <param name="i_sConnectionString"></param>
        /// <returns></returns>
        public NSEGroupDTO GetSingleGroupDetails(string i_sConnectionString, int i_sGroupId)
        {
            PetaPoco.Database db             = null;
            NSEGroupDTO       objGroupobject = new NSEGroupDTO();

            try
            {
                using (db = new PetaPoco.Database(i_sConnectionString, "System.Data.SqlClient")
                {
                    EnableAutoSelect = false
                })
                {
                    using (var scope = db.GetTransaction())
                    {
                        objGroupobject = db.Query <NSEGroupDTO>("exec st_tra_GetGroupDetails @inp_iGroupID",
                                                                new
                        {
                            inp_iGroupID = i_sGroupId
                        }).Single <NSEGroupDTO>();
                        scope.Complete();
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            return(objGroupobject);
        }
Пример #2
0
        /// <summary>
        /// This method is used to save Group Master entries.
        /// <param name="sConnectionString">DB Connection String</param>
        /// <param name="m_objGroupDTO">NSEGroupDTO objects</param>
        /// <returns>if save then return true else return false</returns>
        public IEnumerable <NSEGroupDTO> SaveGroup(string i_sConnectionString, NSEGroupDTO m_objGroupDTO)
        {
            #region Paramters
            int               out_nReturnValue;
            int               out_nSQLErrCode;
            string            out_sSQLErrMessage;
            bool              bReturn = false;
            PetaPoco.Database db      = null;
            #endregion Paramters

            #region Out Paramter
            var nReturnValue = new SqlParameter("@out_nReturnValue", System.Data.SqlDbType.Int);
            nReturnValue.Direction = System.Data.ParameterDirection.Output;
            nReturnValue.Value     = 0;
            var nSQLErrCode = new SqlParameter("@out_nSQLErrCode", System.Data.SqlDbType.Int);
            nSQLErrCode.Direction = System.Data.ParameterDirection.Output;
            nSQLErrCode.Value     = 0;
            var sSQLErrMessage = new SqlParameter("@out_sSQLErrMessage", System.Data.SqlDbType.VarChar);
            sSQLErrMessage.Direction = System.Data.ParameterDirection.Output;
            sSQLErrMessage.Value     = "";
            #endregion Out Paramter

            IEnumerable <NSEGroupDTO> lstGroup = null;
            try
            {
                using (db = new PetaPoco.Database(i_sConnectionString, "System.Data.SqlClient")
                {
                    EnableAutoSelect = false
                })
                {
                    using (var scope = db.GetTransaction())
                    {
                        lstGroup = db.Query <NSEGroupDTO>("exec st_mst_GroupSave @GroupId OUTPUT,@DownloadedDate,@SubmissionDate,@StatusCodeId,@TypeOfDownload,@DownloadStatus,@inp_iLoggedInUserId,@out_nReturnValue OUTPUT,@out_nSQLErrCode OUTPUT,@out_sSQLErrMessage OUTPUT",
                                                          new
                        {
                            GroupId             = m_objGroupDTO.GroupId,
                            DownloadedDate      = DateTime.Now,//m_objGroupDTO.DownloadedDate,
                            SubmissionDate      = m_objGroupDTO.SubmissionDate,
                            StatusCodeId        = 508006,
                            TypeOfDownload      = m_objGroupDTO.TypeOfDownload,
                            DownloadStatus      = false,
                            inp_iLoggedInUserId = m_objGroupDTO.LoggedInUserId,
                            out_nReturnValue    = 1,
                            out_nSQLErrCode     = 1,
                            out_sSQLErrMessage  = string.Empty
                        }).ToList();

                        #region Error Values
                        if (Convert.ToInt32(nReturnValue.Value) != 0)
                        {
                            Exception e = new Exception();
                            out_nReturnValue = Convert.ToInt32(nReturnValue.Value);
                            string sReturnValue = sLookupPrefix + out_nReturnValue;
                            e.Data[0] = sReturnValue;
                            if (nSQLErrCode.Value != System.DBNull.Value)
                            {
                                out_nSQLErrCode = Convert.ToInt32(nSQLErrCode.Value);
                                e.Data[1]       = out_nSQLErrCode;
                            }
                            if (sSQLErrMessage.Value != System.DBNull.Value)
                            {
                                out_sSQLErrMessage = Convert.ToString(sSQLErrMessage.Value);
                                e.Data[2]          = out_sSQLErrMessage;
                            }
                            Exception ex = new Exception(db.LastSQL.ToString(), e);
                            bReturn = false;
                            throw ex;
                        }
                        else
                        {
                            scope.Complete();
                            bReturn = true;
                        }
                        #endregion Error Values
                        return(lstGroup);
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }