예제 #1
0
        public Profile Update(beGreen.Model.Entity.Profile entity)
        {
            using (SqlConnection connection = new SqlConnection(Connection.String))
            {
                SqlCommand command = connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "ProfileUpdate";

                command.Parameters.Add(new SqlParameter("@id", entity.ID));
                command.Parameters.Add(new SqlParameter("@DOB", entity.DOB));
                command.Parameters.Add(new SqlParameter("@Name", entity.Name));
                command.Parameters.Add(new SqlParameter("@Role", entity.Role));


                connection.Open();
                int result = (int)command.ExecuteNonQuery();

                if (result < 1)
                {
                    throw new Exception("Error in UpdateProfile stored procedure.");
                }

                return(entity);
            }
        }
예제 #2
0
        private beGreen.Model.Entity.Profile MapEntity(SqlDataReader data)
        {
            beGreen.Model.Entity.Profile result = new beGreen.Model.Entity.Profile();

            result.ID    = data["ID"].ToString();
            result.Name  = data["Name"].ToString();
            result.DOB   = DateTime.Parse(data["DOB"].ToString());
            result.Role  = data["Role"].ToString();
            result.Email = data["Email"].ToString();

            return(result);
        }
예제 #3
0
        public bool Create(beGreen.Model.Entity.Profile entity)
        {
            using (SqlConnection connection = new SqlConnection(Connection.String))
            {
                SqlCommand command = connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "ProfileCreate";

                command.Parameters.Add(new SqlParameter("@ID", entity.ID));
                command.Parameters.Add(new SqlParameter("@DOB", entity.DOB));
                command.Parameters.Add(new SqlParameter("@Name", entity.Name));
                command.Parameters.Add(new SqlParameter("@Role", entity.Role));
                command.Parameters.Add(new SqlParameter("@Email", entity.Email));

                connection.Open();
                int result = (int)command.ExecuteNonQuery();

                return(result == 1 ? true : false);
            }
        }