public JsonResult Update(SectionModal section)
        {
            section.SemesterId = GetSemesterId(Int32.Parse(section.SemesterNo));


            return(Json(_databaseConnection.Update(section), JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public object Update(SectionModal section)
        {
            int noOfRowsAffected = 0;

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand("spUpdateSection", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Id", section.Id);
                command.Parameters.AddWithValue("@SessionId", section.SessionId);
                command.Parameters.AddWithValue("@SemesterId", section.SemesterId);
                command.Parameters.AddWithValue("@SectionName", section.SectionName);
                command.Parameters.AddWithValue("@Shift", section.Shift);



                try
                {
                    noOfRowsAffected = command.ExecuteNonQuery();
                }
                catch (SqlException exc)
                {
                    return(0);
                }
            }

            return(noOfRowsAffected);
        }
Example #3
0
        } //List Method

        // Insert
        public int Insert(SectionModal section)
        {
            bool isDuplicate = CheckPrimaryKeyViolation(section.SemesterId, section.SessionId, section.SectionName);

            if (isDuplicate)
            {
                return(0);
            }


            int noOfRowsAffected = 0;

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();

                SqlCommand command = new SqlCommand("spInsertSection", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@SessionId", section.SessionId);
                command.Parameters.AddWithValue("@SemesterId", section.SemesterId);
                command.Parameters.AddWithValue("@SectionName", section.SectionName);
                command.Parameters.AddWithValue("@Shift", section.Shift);


                try
                {
                    noOfRowsAffected = command.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2627)
                    {
                        return(0);
                    }
                }
            }

            return(noOfRowsAffected);
        } // Insert Method
 public JsonResult Insert(SectionModal sectionObject)
 {
     return(Json(_databaseConnection.Insert(sectionObject), JsonRequestBehavior.AllowGet));
 }