Example #1
0
        public bool District_Update(IdentityDistrict identity)
        {
            //Common syntax
            var sqlCmd = @"District_Update";

            //For parameters
            var parameters = new Dictionary <string, object>
            {
                { "@Id", identity.Id },
                { "@Name", identity.Name },
                { "@Code", identity.Code },
                { "@Status", identity.Status }
            };

            try
            {
                using (var conn = new SqlConnection(_connectionString))
                {
                    MsSqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, sqlCmd, parameters);
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute District_Update. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }

            return(true);
        }
Example #2
0
        public IdentityDistrict District_GetById(int Id)
        {
            var info   = new IdentityDistrict();
            var sqlCmd = @"District_GetById";

            var parameters = new Dictionary <string, object>
            {
                { "@Id", Id }
            };

            try
            {
                using (var conn = new SqlConnection(_connectionString))
                {
                    using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters))
                    {
                        while (reader.Read())
                        {
                            info = ExtractDistrictData(reader);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute District_GetById. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }
            return(info);
        }
Example #3
0
        private IdentityDistrict ExtractDistrictData(IDataReader reader)
        {
            var record = new IdentityDistrict();

            //Seperate properties
            record.Id   = Utils.ConvertToInt32(reader["Id"]);
            record.Name = reader["Name"].ToString();
            record.Code = reader["Code"].ToString();

            record.Status = Utils.ConvertToInt32(reader["Status"]);

            return(record);
        }
Example #4
0
 public bool District_Update(IdentityDistrict identity)
 {
     return(myRepository.District_Update(identity));
 }
Example #5
0
 public bool District_Insert(IdentityDistrict identity)
 {
     return(myRepository.District_Insert(identity));
 }