Beispiel #1
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- Update ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Converts the object properties to SQL paramters and executes the update procedure.
        /// </summary>
        /// <param name="IndexersWithJournalsObj">Model object.</param>
        /// <returns>The result of update query.</returns>
        //--------------------------------------------------------------------
        public bool Update(IndexersWithJournalsModel IndexersWithJournalsObj)
        {
            bool result = false;
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("[dbo].[IndexersWithJournals_Update]", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                //----------------------------------------------------------------------------------------------
                // Set the parameters
                //----------------------------------------------------------------------------------------------
                
				myCommand.Parameters.Add("@ID", SqlDbType.Int).Value = IndexersWithJournalsObj.ID;
				myCommand.Parameters.Add("@IndexerID", SqlDbType.Int).Value = IndexersWithJournalsObj.IndexerID;
				myCommand.Parameters.Add("@JournalCode", SqlDbType.VarChar).Value = IndexersWithJournalsObj.JournalCode;
				myCommand.Parameters.Add("@SubmissionDate", SqlDbType.Date).Value = IndexersWithJournalsObj.SubmissionDate;
				myCommand.Parameters.Add("@AcceptanceDate", SqlDbType.Date).Value = IndexersWithJournalsObj.AcceptanceDate;
				myCommand.Parameters.Add("@RejectionDate", SqlDbType.Date).Value = IndexersWithJournalsObj.RejectionDate;
				myCommand.Parameters.Add("@NextEvaRound", SqlDbType.NVarChar).Value = IndexersWithJournalsObj.NextEvaRound;
				myCommand.Parameters.Add("@NoofEvaRound", SqlDbType.Int).Value = IndexersWithJournalsObj.NoofEvaRound;
				myCommand.Parameters.Add("@Notes", SqlDbType.NVarChar).Value = IndexersWithJournalsObj.Notes;
				myCommand.Parameters.Add("@StatusID", SqlDbType.Int).Value = IndexersWithJournalsObj.StatusID;

                //----------------------------------------------------------------------------------------------
                // Execute the command
                //----------------------------------------------------------------------------------------------
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    result = true;
                }
                myConnection.Close();
                return result;
                //----------------------------------------------------------------------------------------------
            }
        }
Beispiel #2
0
 public ActionResult Update(IndexersWithJournalsModel IndexersWithJournalsObj)
 {
     //------------------------------------------
     //Check ModelState
     //------------------------------------------
     if (!ModelState.IsValid)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Invalid data"));
     }
     //------------------------------------------
     try
     {
         bool result = IndexersWithJournalsFactor.Update(IndexersWithJournalsObj);
         if (result == true)
         {
             return(List(1, 25, null, null, null, null));
         }
         else
         {
             return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Saving operation faild"));
         }
     }
     catch (Exception ex)
     { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message)); }
 }
Beispiel #3
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region --------------GetObject--------------
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the spesific record.
        /// </summary>
        /// <param name="ID">The model id.</param>
        /// <returns>Model object.</returns>
        //--------------------------------------------------------------------
        public static IndexersWithJournalsModel GetObject(int ID)
        {
            IndexersWithJournalsModel        IndexersWithJournalsObj = null;
            List <IndexersWithJournalsModel> list = IndexersWithJournalsSqlDataPrvider.Instance.Get(ID);

            if (list != null && list.Count > 0)
            {
                IndexersWithJournalsObj = list[0];
            }
            return(IndexersWithJournalsObj);
        }
Beispiel #4
0
 public ActionResult GetObject(int id)
 {
     try
     {
         IndexersWithJournalsModel IndexersWithJournalsObj = IndexersWithJournalsFactor.GetObject(id);
         if (IndexersWithJournalsObj == null)
         {
             IndexersWithJournalsObj = new IndexersWithJournalsModel();
         }
         return(Json(IndexersWithJournalsObj, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Beispiel #5
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- Create ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Converts the  object properties to SQL paramters and executes the create  procedure 
        /// and updates the object with the SQL data by reference.
        /// </summary>
        /// <param name="IndexersWithJournalsObj">Model object.</param>
        /// <returns>The result of create query.</returns>
        //--------------------------------------------------------------------
        public bool Create(IndexersWithJournalsModel IndexersWithJournalsObj)
        {
            bool result = false;
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("[dbo].[IndexersWithJournals_Create]", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                //----------------------------------------------------------------------------------------------
                // Set the parameters
                //----------------------------------------------------------------------------------------------
				myCommand.Parameters.Add("@ID", SqlDbType.Int, 4).Direction = ParameterDirection.Output;
				myCommand.Parameters.Add("@IndexerID", SqlDbType.Int, 4).Value = IndexersWithJournalsObj.IndexerID;
				myCommand.Parameters.Add("@JournalCode", SqlDbType.VarChar, 20).Value = IndexersWithJournalsObj.JournalCode;
				myCommand.Parameters.Add("@SubmissionDate", SqlDbType.Date, 3).Value = IndexersWithJournalsObj.SubmissionDate;
				myCommand.Parameters.Add("@AcceptanceDate", SqlDbType.Date, 3).Value = IndexersWithJournalsObj.AcceptanceDate;
				myCommand.Parameters.Add("@RejectionDate", SqlDbType.Date, 3).Value = IndexersWithJournalsObj.RejectionDate;
				myCommand.Parameters.Add("@NextEvaRound", SqlDbType.NVarChar, 128).Value = IndexersWithJournalsObj.NextEvaRound;
				myCommand.Parameters.Add("@NoofEvaRound", SqlDbType.Int, 4).Value = IndexersWithJournalsObj.NoofEvaRound;
				myCommand.Parameters.Add("@Notes", SqlDbType.NVarChar, 2000).Value = IndexersWithJournalsObj.Notes;
				myCommand.Parameters.Add("@StatusID", SqlDbType.Int, 4).Value = IndexersWithJournalsObj.StatusID;

                //----------------------------------------------------------------------------------------------
                // Execute the command
                //----------------------------------------------------------------------------------------------
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    result = true;
                    //Get ID value from database and set it in object
				IndexersWithJournalsObj.ID = (int)myCommand.Parameters["@ID"].Value;

                }
                myConnection.Close();
                return result;
                //----------------------------------------------------------------------------------------------
            }
        }
Beispiel #6
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- PopulateModelFromIDataReader ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Populates model from IDataReader .
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>Model object.</returns>
        //--------------------------------------------------------------------
        private IndexersWithJournalsModel PopulateModelFromIDataReader(IDataReader reader)
        {
            //Create a new object
            IndexersWithJournalsModel IndexersWithJournalsObj = new IndexersWithJournalsModel();
            //Fill the object with data

			//------------------------------------------------
			//[ID]
			//------------------------------------------------
			if (reader["ID"] != DBNull.Value)
			    IndexersWithJournalsObj.ID = (int)reader["ID"];
			//------------------------------------------------
			//------------------------------------------------
			//[IndexerID]
			//------------------------------------------------
			if (reader["IndexerID"] != DBNull.Value)
			    IndexersWithJournalsObj.IndexerID = (int)reader["IndexerID"];
			//------------------------------------------------
			//------------------------------------------------
			//[JournalCode]
			//------------------------------------------------
			if (reader["JournalCode"] != DBNull.Value)
			    IndexersWithJournalsObj.JournalCode = (string)reader["JournalCode"];
			//------------------------------------------------
			//------------------------------------------------
			//[SubmissionDate]
			//------------------------------------------------
			if (reader["SubmissionDate"] != DBNull.Value)
			    IndexersWithJournalsObj.SubmissionDate = (DateTime)reader["SubmissionDate"];
			//------------------------------------------------
			//------------------------------------------------
			//[AcceptanceDate]
			//------------------------------------------------
			if (reader["AcceptanceDate"] != DBNull.Value)
			    IndexersWithJournalsObj.AcceptanceDate = (DateTime)reader["AcceptanceDate"];
			//------------------------------------------------
			//------------------------------------------------
			//[RejectionDate]
			//------------------------------------------------
			if (reader["RejectionDate"] != DBNull.Value)
			    IndexersWithJournalsObj.RejectionDate = (DateTime)reader["RejectionDate"];
			//------------------------------------------------
			//------------------------------------------------
			//[NextEvaRound]
			//------------------------------------------------
			if (reader["NextEvaRound"] != DBNull.Value)
			    IndexersWithJournalsObj.NextEvaRound = (string)reader["NextEvaRound"];
			//------------------------------------------------
			//------------------------------------------------
			//[NoofEvaRound]
			//------------------------------------------------
			if (reader["NoofEvaRound"] != DBNull.Value)
			    IndexersWithJournalsObj.NoofEvaRound = (int)reader["NoofEvaRound"];
			//------------------------------------------------
			//------------------------------------------------
			//[Notes]
			//------------------------------------------------
			if (reader["Notes"] != DBNull.Value)
			    IndexersWithJournalsObj.Notes = (string)reader["Notes"];
			//------------------------------------------------
			//------------------------------------------------
			//[StatusID]
			//------------------------------------------------
			if (reader["StatusID"] != DBNull.Value)
			    IndexersWithJournalsObj.StatusID = (int)reader["StatusID"];
			//------------------------------------------------
            //Return the populated object
            return IndexersWithJournalsObj;
        }
Beispiel #7
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region --------------Update--------------
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Updates model object by calling sql data provider update method.
        /// </summary>
        /// <param name="IndexersWithJournalsObj">The model object.</param>
        /// <returns>The result of update operation.</returns>
        //--------------------------------------------------------------------
        public static bool Update(IndexersWithJournalsModel IndexersWithJournalsObj)
        {
            return(IndexersWithJournalsSqlDataPrvider.Instance.Update(IndexersWithJournalsObj));
        }